Looping 302 redirect

Hi everyone, please help me figure what i am doing wrong.

$URL = https://example.com because of new user limit

A domain is transferred to Cloudflare, and the A record points to its IP address. The site is working as it should.

Now, enabling proxying in Cloudflare i get never ending 302 redirect loop:

Request URL: $URL
Request Method: GET
Status Code: 302 Moved Temporarily
Remote Address: 104.27.188.13:80
Referrer Policy: no-referrer-when-downgrade
CF-Cache-Status: DYNAMIC
CF-RAY: 59c96c857a93048b-CDG
cf-request-id: 0311c2276e0000048b5b09e200000001
Connection: keep-alive
Content-Type: text/html
Date: Mon, 01 Jun 2020 13:53:58 GMT
Location: $URL
Server: cloudflare
Transfer-Encoding: chunked

As you can see, there is a forever 302 redirect from $URL to $URL. I have no page rules doing HTTPS rewrites or redirects, and Always use HTTPS is disabled, as i want my server to do the redirects from www to non-www and from http to https.

Here’s the nginx config on the origin server: http://p.ip.fi/kdbi

Which SSL mode are you using on the SSL/TLS page? It should be Full (Strict).

1 Like

Thank you @sdayman, that fixed it. Can you please explain what was my error here?

You didn’t say what your SSL Mode was, but that determines how Cloudflare connects to your server. If it’s a mismatch (HTTP vs. HTTPS), your server will send a 301/302 telling Cloudfare to use the other method.

This topic was automatically closed after 14 days. New replies are no longer allowed.