Fixing “Too many HTTP redirects” errors with Cloudflare + Ghost blog
I was recently working on moving this blog to a new domain (philz.blog). It is set up as a Ghost self-hosted instance on a DigitalOcean droplet. And, as usual, I wanted Cloudflare in front of the traffic.
So, I set up the new domain, then SSH'ed into the server and ran:
cd /var/www/ghost
ghost config url https://philz.blog
ghost setup nginx
ghost setup ssl
ghost restart
With this admittedly standard setup, I was expecting pretty much immediate success – after all, I've done this before, the domain's DNS records are very standard, and I didn't customize anything on the Cloudflare end.
Unfortunately, what I got was a nasty 301 redirect loop. In Safari (my default browser of choice), this manifested as a series of “Load cannot follow more than 20 redirections” errors.
Some debugging proved this was a legitimate 301 redirect loop:

My first guess was to blame Ghost's nginx setup. But, the logs were suggesting nothing odd was happening:
ghost log
[2024-12-21 19:55:38] INFO "GET /" 301 1ms
[2024-12-21 19:55:38] INFO "GET /" 301 1ms
[2024-12-21 19:55:38] INFO "GET /" 301 1ms
The next possible culprit was Cloudflare. I had not customized any of the settings there yet, so I was pretty much running on the default configuration.
However, it turns out that the default configuration included the "Flexible SSL" encryption mode option. This mode encrypts browser-Cloudflare network traffic over HTTPS. However, Cloudflare sends unencrypted HTTP requests to your origin web server when enabled. Redirect loops may occur if your origin web server redirects all HTTP requests to HTTPS.
The solution was fairly straightforward and obvious: selecting the "Full (Strict)" option instead. This resolved the 301 redirect loops immediately.
I am by no means a web technology expert, but finding a note like this one could've saved an hour of my time. Who knows, maybe jotting this down will turn out to be helpful – for myself or someone else.