Search code examples
nginxcloudflare

Nginx and Cloudflare: err_too_many_redirects


The error err_too_many_redirects appears in the browser enter image description here but nothing comes out in the nginx error log and I just registered the site in cloudflare. All traffic is redirected to HTTPS


Solution

  • This error generally occurs in Wordpress Sites which is due to a re-direct header sent by PHP.

    So This is due to following reason:

    1. You have enabled HTTPS redirect on your website either by ngin or php.
    2. Cloudflare tries to open your site http://example.com and proxy it with https
    3. When Cloudflare tries to open http://example.com, your site tells it to open https://example.com and cloudflare again tries to open http://example.com
    4. This forms a redirect loop and due to which site could not open.

    The best way to solve this is :

    1. Disable HTTPS Redirect from your server side.
    2. Enable Flexible SSL from Cloudflare
    3. Enter a page rule on Cloudflare with input as http://*.example.com to Always use HTTPS