ERR_TOO_MANY_REDIRECTS with nginx

In my case it was Cloudflare. I had to change to Full SSL encryption


Change your config to below

server {
        listen 80 default_server;
        server_name mywebsite.me www.mywebsite.me;

        return 301 https://$server_name$request_uri;
}

server {

        listen 443 ssl default_server;

        ssl_certificate /etc/letsencrypt/live/mywebsite.me/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/mywebsite.me/privkey.pem;

        root /home/website/mywebsite/public;

        index index.html index.htm index.php;

        server_name mywebsite.me www.mywebsite.me;

        location / {
                try_files $uri $uri/ /index.php$is_args$args;
        }

        location ~ \.php$ {
                include snippets/fastcgi-php.conf;
                fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
        }
}

Your current config redirects on both http and https to https. So it becomes a infinite loop because of the return statement. You want return statement only when connection is http. So you split it into two server blocks


i had the same problem. i found lots of questions/answers and articles about it but nothing helped. i then tried to access my site from a different browser and it worked just fine! deleting the cache from my chrome browser solved it.

So - keep in mind when you try different solutions to also clear your cache