This is a very similar problem to Nginx configuration leads to endless redirect loop but that discussion has not led me to an answer yet. I\'m learning how to work with ngin
I've toyed around with other answers but nothing worked for me. Then I realized since I use Cloudflare the problem may not be in the server but with Cloudflare. Lo and behold when I set my SSL to Full (Strict)
everything works as it should!
When nginx encounters a https
protocol it thinks it is still using http
as the protocol and is not being forwarded with the rest of the headers, try adding:
proxy_set_header X-Forwarded-Proto $scheme;
in your location blocks to fix it.