0

Im having an issue with https redirects. Ive tested in chrome, firefox and safari.

When i load my website using https i get the errors

Firefox: "The page isn't redirecting properly" Chrome: "ERR_TOO_MANY_REDIRECTS" Safari: "Too many redirects occuring"

Nginx conf

server {
    listen 80;
    return 301 https://$host$request_uri;
}

server {
    listen       443 ssl;
    server_name  example.com;

    ssl on;
    ssl_certificate /etc/nginx/ssl/server.crt;
    ssl_certificate_key /etc/nginx/ssl/server.key; 
    ssl_session_timeout 1d;
    ssl_session_cache shared:SSL:50m;
    ssl_session_tickets off;

    ssl_dhparam /etc/nginx/ssl/dhparam.pem;

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers 'ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:!DSS';
    ssl_prefer_server_ciphers on;

    add_header Strict-Transport-Security max-age=15768000;

#    ssl_stapling on;
#    ssl_stapling_verify on;

    resolver 8.8.8.8;

    #access_log  logs/host.access.log  main;

    location / {
        root   /srv/public;
        index  index.php;
    # example
        #ModSecurityEnabled on;
        #ModSecurityConfig /etc/nginx/modsecurity.conf;
    }

    error_page  404              /404.html;
    location = /404.html {
        root   /usr/share/nginx/html;
    }

    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }

    location ~ \.php$ {
        root           /srv/public;
        fastcgi_pass   unix:/var/run/php-fpm.sock;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME   $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }

}

I am using a piece of software (whmcs) which has its own built in https redirect.

I'm also using cloudflare (SSL set to Full - not strict).

If i remove the https url from the software (whmcs) I can manually navigate to https://example.com. and it works fine.

Im guessing that the issue may be a combination of cloudflare whmcs and my nginx configuration together but i cant work out whats going wrong.

when i nagivate to https://example.com, i can see in firebug a number of 302 status codes, and in the header it shows location as http://example.com.

2
  • The SSL type has caused this type of problem for me before - both the main setting and inside page rules. Subtle things can cause this redirect loop. First thing to do is hard code the IP in your hosts file and see if it works without CloudFlare. If that works put CF back on and look at the site using curl or Firefox and the "Live HTTP Headers" plugin. Post the output of that (or curl) and the nginx access / error logs.
    – Tim
    Apr 15, 2016 at 20:38
  • a number of 302 status codes, and in the header it shows location as http://example.com. cloudflare won't be issuing those, and neither nginx with the config in the question which leaves: the php application.
    – AD7six
    Jun 10, 2016 at 5:58

0

You must log in to answer this question.

Browse other questions tagged .