Cloudflare Pages redirect loop

Hi,

I’m trying to deploy my blog to Cloudflare Pages with a custom domain but all requests are redirecting to an HTTP URL of the site and then a 1-step redirect loop after that.

I would tell you what the site is, but the forum software says I can’t include links in my posts.

The pages.dev URL is [redacied] and that one works correctly.

The site is hosted on GitHub and I deployed it with GitHub Actions. I do not have any _redirect files or page rules.

These are the headers I’m getting for the custom domain URL:

$ curl -I https://blog.bityard.net
HTTP/2 301 
date: Fri, 24 Jun 2022 23:59:52 GMT
location: http://blog.bityard.net/
cache-control: max-age=3600
expires: Sat, 25 Jun 2022 00:59:52 GMT
expect-ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
report-to: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=DQz99o5rCT3nav62mGK5Hh773cg7y03%2F1%2BvhJdthMYJZ4SJ5LDMzWwH%2FORe0RtHpnzGyjzNGLMql60upDm0Hl7tVB0TuOTyDCwlauBfpmVZ%2F9PYO5ZhP4FGv5hKn5YBNdatR"}],"group":"cf-nel","max_age":604800}
nel: {"success_fraction":0,"report_to":"cf-nel","max_age":604800}
server: cloudflare
cf-ray: 72096b6f8d4c78dc-EWR

I can see the CNAME record in the DNS settings for the domain and it looks correct. But when I query the domain (directly against a Cloudflare resolver), I’m getting A records instead of a CNAME record back:

$ dig blog.bityard.net @dee.ns.cloudflare.com

; <<>> DiG 9.16.1-Ubuntu <<>> blog.bityard.net @dee.ns.cloudflare.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 64961
;; flags: qr aa rd; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1
;; WARNING: recursion requested but not available

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1232
;; QUESTION SECTION:
;blog.bityard.net.		IN	A

;; ANSWER SECTION:
blog.bityard.net.	300	IN	A	172.67.191.95
blog.bityard.net.	300	IN	A	104.21.84.105

;; Query time: 23 msec
;; SERVER: 172.64.32.93#53(172.64.32.93)
;; WHEN: Fri Jun 24 20:02:40 EDT 2022
;; MSG SIZE  rcvd: 77

It’s been about 45 minutes at this point, does it take a long time for Cloudflare’s DNS servers to update themselves and I’m being impatient, or is there a problem?

The DNS is fine; Cloudflare turns that into an A record behind the scenes to do its Magic™️.

Something is creating a redirect from your HTTPS site to HTTP. There’s certainly no switch for that in the settings, so maybe double-check all the settings for your zone?

2 Likes

It turns out you were on the right track. Up until now, I have mainly used Cloudflare for DNS and didn’t bother with any of the other services or settings but at some point I must have turned off SSL/TLS for the reverse proxy service. Couldn’t tell you when or why but ultimately it meant (apparently) that Cloudflare was trying to do an HTTP redirect to itself.

So if anyone else finds this, make sure that SSL/TLS is enabled for the domain or your Cloudflare Pages site isn’t going to work.

Thanks i40west for the tip.

1 Like

Thanks for clarifying which setting was responsible. It will help in the future :slightly_smiling_face:

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