title: How to make nginx redirect based on the value of a header?
body: <p>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. </p>
  
  <p>To distinguish between the two, Cloudflare includes an <code>X-Forwarded-Proto</code> header which is set to "http" or "https" based on the user's connection.</p>
  
  <p>I would like to redirect every request with an <code>X-Forwarded-Proto: http</code> header to the SSL version of my site. How can I achieve this with an nginx configuration?</p>