Redirect loop when enable Cloudflare

Last week, I mistakenly enabled something called “analytics” on Cloudflare by clicking a link and my website immediately cannot be accessed, issue is domain http://pokrex.com redirects to https://pokrex.com and https://pokrex.com redirects to http://pokrex.com, I have to switch back to Godaddy for the temp solution.

This morning, I set Cloudflare as the DNS server and try to solve this, but no luck, it still does the redirection. This was working before until I click that link…Any insights?

I use own TLS certificate from Letsencrypt and TLS configurations and directions are in Nginx.

Curl:

$ curl -I http://pokrex.com
HTTP/1.1 301 Moved Permanently
Date: Sun, 07 Jun 2020 02:38:00 GMT
Content-Type: text/html
Connection: keep-alive
Set-Cookie: __cfduid=d4ba75cf6dbec8305c3f368acd0a762101591497480; expires=Tue, 07-Jul-20 02:38:00 GMT; path=/; domain=.pokrex.com; HttpOnly; SameSite=Lax
Location: https://pokrex.com/
CF-Cache-Status: DYNAMIC
cf-request-id: 032e3d6f9a0000c16b1b0af200000001
Server: cloudflare
CF-RAY: 59f6fe929be0c16b-IAD

$ curl -I https://pokrex.com
HTTP/1.1 301 Moved Permanently
Date: Sun, 07 Jun 2020 02:14:37 GMT
Connection: keep-alive
Cache-Control: max-age=3600
Expires: Sun, 07 Jun 2020 03:14:37 GMT
Location: http://pokrex.com/
cf-request-id: 032e2809130000c1e836872200000001
Expect-CT: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
Server: cloudflare
CF-RAY: 59f6dc54e8b0c1e8-IAD

Some of my Nginx configrations:

server {
  listen 80;
  server_name pokrex.com;

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

server {
  listen 443 ssl http2 default_server;
  server_name pokrex.com;
  if ($host != 'pokrex.com') {
    return 301 https://pokrex.com$request_uri;
  }
}

OK, I just “paused Cloudflare on Site” from “Advanced Actions” section, seems the DNS resolve is good now.

Can someone share some insights how to resolve this redirection loop when I enable Cloudflare?

Once enabled “SSL/TLS”, this seems to work. I’m not sure why disable SSL/TLS would result to redirect loop.

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