Welcome! Log In Create A New Profile


Too many redirects

Posted by marekkk 
Too many redirects
October 21, 2018 12:08PM
Good day,

I have a problem with my site not loading due to 'too many redirects'. The issue is not browser or PC dependant. It seems to depend on the modem / connection used. On the same laptop it will either work in all browsers or work in no browser, depending on how it is connected to the internet. On some networks, the site will load fine, on others it will produce 'too many redirects' in all cases.

The nginx server redirects unknown subdomains and unencrypted connections to https (301).
When it fails, it will redirect https//www.mysite.com to itself indefinitely.

Does anyone know what could be causing this? Maybe some server header I am setting? Here is my configuration:

# redirect all http requests to https
server {
listen 80 ;
listen [::]:80 ;

#server_name _;

# ssl settings
include /etc/nginx/templates/ssl.tmpl;

if ($http_x_forwarded_proto = "http") {
return 301 https://$host$request_uri;
#return 301 https://$server_name$request_uri;

# redirect all unknown urls to https://www.mysite.com
server {
listen 80 default_server;
listen [::]:80 default_server;

listen 443 ssl default_server;
listen [::]:443 ssl default_server;

server_name _;
log_not_found off;

# ssl settings
include /etc/nginx/templates/ssl.tmpl;

return 301 https://www.mysite.com;

server {
listen 443 ssl;

proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

set_real_ip_from ::ffff:;
set_real_ip_from ::ffff:;

real_ip_header X-Forwarded-For;
real_ip_recursive on;

root /var/www/www.mysite.com/;
server_name www.mysite.com;

# allow access from all domains
add_header Access-Control-Allow-Origin *;

index index.html index.htm;
client_max_body_size 3M;

# ssl settings
include /etc/nginx/templates/ssl.tmpl;
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 102
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready