Semaphorism reported an SSL redirect loop (ERR_TOO_MANY_REDIRECTS) when running Discourse behind Nginx, using ports 5001 (HTTP) and 5002 (HTTPS), with a config based on a DigitalOcean tutorial. After initially claiming to have fixed it by updating the Nginx config to properly set proxy headers and use localhost instead of the domain, Semaphorism later clarified the issue persisted intermittently across devices and browsers. They discovered the root cause was Cloudflare’s proxying — disabling Cloudflare routing resolved the loop. mpalmer suggested notifying DigitalOcean to update their outdated article. Key takeaway: When using Cloudflare with Discourse + Nginx, proxying can interfere with SSL redirects; test by disabling Cloudflare or bypassing it via hosts file. Ensure Nginx correctly forwards headers like X-Forwarded-Proto to avoid misconfigured redirects.
I have Discourse on port 5001 (HTTP), and 5002 (HTTPS), but the problem is that its redirect looping, also known as ERR_TOO_MANY_REDIRECTS on Chrome.
My Nginx configuration, with SSL. I got this configuration from DigitalOcean, specifically this article
I changed the SSL certificates, as well as the domain, and the port that I use. The configuration is using Lets Encrypt.
I am still having the redirect loop issue, but only on some of my devices, and some browsers. I am completely unsure what is happening now, and could use help from someone with good experience with nginx.
I should also mention the website is behind cloudflare, which may have a factor in this issue, or could be the issue itself, unsure.
Edit: I disabled routing through cloudflare, and it appears to have resolved my issue, so take note, if you have a redirect issue using when using cloudflare, try disabling the routing for a bit of time and see if it fixes it. If you can’t disable that, then try changing your DNS to your server manually via hosts file.