ERR_TOO_MANY_REDIRECTS after moving DNS to CF

I am getting the following error after pointing the domain to CF servers. It did not happen initially but about 24 hours later.

image

Can anyone give a clue about this?

I use a Lightsail (AWS) instance with a Linux box and Nginx

Thanks

Hi, can you look through the information and advice in this tutorial and let us know if you still have any issues:

Often this can be resolved by changing the SSL configuration from “Flexible” to “Full (Strict)”, so I would recommend trying that especially. Let us know if you have any other issues or questions.

1 Like

The curl command in your article gives me NOTHING. I am not sure why.

Can you please check the configuration below for any red flags? It was working just fine before.

server {
        listen [::]:80;
        listen 80;

        server_name mydomain.com www.mydomain.com;

        return 301 https://www.mydomain.com$request_uri;
}

server {
        listen [::]:443 ssl http2;
        listen 443 ssl http2;
        server_name mydomain.com;

        ssl_certificate /etc/ssl/mydomain.com/with-business-ownership/mydomain.com.crt;
        ssl_certificate_key /etc/ssl/mydomain.com/with-business-ownership/mydomain.com_key.txt;

        error_log  /var/www/html/mydomain/logs/error.log;

        root  /var/www/html/mydomain/production/;
        index index.html index.php;

        return 301 https://www.mydomain.com$request_uri;
}

server {
        listen 443 ssl http2;
        listen [::]:443 ssl http2;
        server_name www.mydomain.com;

        ssl_certificate /etc/ssl/mydomain.com/with-business-ownership/mydomain.com.crt;
        ssl_certificate_key /etc/ssl/mydomain.com/with-business-ownership/mydomain.com_key.txt;


        error_log  /var/www/html/mydomain/logs/error.log;

        root  /var/www/html/mydomain/production/;
        index index.html index.php;

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

        location = /favicon.ico {
                log_not_found off;
                access_log off;
        }

        location ~ \.php$ {
                try_files $uri =404;
                fastcgi_split_path_info ^(.+.php)(/.+)$;
                fastcgi_pass unix:/run/php/php7.4-fpm.sock;
                fastcgi_read_timeout 3600;
                fastcgi_index index.php;
                fastcgi_buffers 16 16k;
                fastcgi_buffer_size 32k;
                include fastcgi_params;
        }
}

Your HTTP port 80 is redirecting to the HTTPS version of the site, which may cause this error.

Can you check on the Cloudflare dashboard under SSL/TLS what the mode is set to? If it is “Flexible” then please set it to “Full (Strict)” and try agaiin.

1 Like

This is what is showing in CF dashboard

The below is not set to full strict

Apologies as in the article you sent I understood to check full strict settings in the actual server, not in CF settings. Changing that in CF did the trick. It is all fixed. I was going crazy with that.

2 Likes

So, for anyone who has this issue in the future. Please check the location in CF below:

1 Like

On another note @Erisa . Should I enable “SSL/TLS Recommender”?

There is no need to, if Full (strict) is working. All the SSL/TLS Recommender does is let you know when you can safely increase the SSL/TLS mode to a more secure one, but you already have the site working on the most secure option, so it wouldn’t do anything.

I have another problem after I started working. The old site name l. the current domain dot com is now not working at all. That is the legacy site.

This is the legacy site configuration

server {

        listen 443 ssl;
        listen [::]:443 ssl; # ipv6only=on;

        root /var/www/html/mydomain/mydomain-production;

        index index.php;

        server_name l.mydomain.com www.l.mydomain.com _;

        ssl on;
        ssl_certificate /etc/letsencrypt/live/l.mydomain.com/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/l.mydomain.com/privkey.pem;

        location / {
                try_files $uri $uri/ @handler;
        }

        location ~ \.php$ {
                try_files     $uri @handler;
                fastcgi_split_path_info  ^(.+\.php)(/.+)$;
                fastcgi_index            index.php;
                fastcgi_pass             unix:/var/run/php/php7.4-fpm.sock;
                include                  fastcgi_params;
                fastcgi_read_timeout 300;
                fastcgi_param   PATH_INFO       $fastcgi_path_info;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        }

        location @handler {
                index mydomain/mydomain-production/cart.php;
                rewrite ^/sitemap.xml(\?.+)?$ /cart.php?target=sitemap;
                rewrite ^/(.*)$ /cart.php?url=$1 last;
        }

}

This is what looks like in CF DNS dashboard

image

The error is finding www.I, not just I.

I have added one directly in CF DNS settings with “www.l” now. How long should I wait until it takes effect? Do I have to change the Nginx configuration mentioned above?

image

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.