I'm hosting a website behind a Cloudflare proxy, which means that all requests to my server are over port 80, even though Cloudflare handles HTTP (port 80) and HTTPS (port 443) traffic.
To distinguish between the two, Cloudflare includes an X-Forwarded-Proto
header which is set to "http" or "https" based on the user's connection.
I would like to redirect every request with an X-Forwarded-Proto: http
header to the SSL version of my site. How can I achieve this with an nginx configuration?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…