Nginx - redirected you too many times

Hi, I'm using Ubuntu 18.04 LTS and I setup LEMP stack using Webinoly. I uploaded an existing wordpress website and enabled SSL using site domain.com -ssl-on. But I'm getting the error "domain.com redirected you too many times." Here's my nginx configuration.

    server {
            listen 80;
            listen [::]:80;
            server_name iflytravelsolutionsinc.com www.iflytravelsolutionsinc.com;
            return 301 https://$host$request_uri;
    }

    server {
            listen 443 ssl http2 default_server;
            listen [::]:443 ssl http2 default_server;

            server_name iflytravelsolutionsinc.com www.iflytravelsolutionsinc.com;

            # WebinolySSLstart
            ssl_certificate /etc/letsencrypt/live/iflytravelsolutionsinc.com/fullchain.pem;
            ssl_certificate_key /etc/letsencrypt/live/iflytravelsolutionsinc.com/privkey.pem;
            ssl_stapling on;
            ssl_stapling_verify on;
            ssl_trusted_certificate /etc/letsencrypt/live/iflytravelsolutionsinc.com/chain.pem;
            # WebinolySSLend
            access_log /var/log/nginx/iflytravelsolutionsinc.com.access.log we_log;
            error_log /var/log/nginx/iflytravelsolutionsinc.com.error.log;

            root /var/www/iflytravelsolutionsinc.com/htdocs;

            index  index.php index.html index.htm;

            include common/php.conf;
            include common/wpcommon.conf;
            include common/locations.conf;
            include common/headers-http.conf;
            include common/headers-https.conf;
            include common/headers-html.conf;
            include /var/www/iflytravelsolutionsinc.com/*-nginx.conf;
    }           

1 Reply

Hey @marccaps - based off of the redirect error message you're seeing, it sounds like you're caught in a redirect loop. That means that the site is being continuously redirected between addresses and can't complete. This Liquid Web article has a great explanation of how this can happen.

Via Stack Overflow, It looks like another user ran into a similar issue after enabling their SSL with Cloudflare. It looks like they were able to solve their issue with some changes to their Nginx configuration formatting:

HTTP to HTTPS Nginx too many redirects

Likewise, this other user was able to solve the issue with some different (but simple) configuration formatting changes:

Nginx configuration leads to endless redirect loop

If you haven't figured it out already, I hope these point you in the right direction! If you did fix the issue, I'd be curious to know which configuration changes you made to get things working.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct