× {{alert.msg}} Never ask again
Get notified about new tutorials RECEIVE NEW TUTORIALS

HTTPS/SSL redirection with Nginx behind Cloudfront

Rick van Hattem
Jun 11, 2015
<p>One important thing to note here is that the content from the origin server will <strong>always </strong>be transferred through <strong>http</strong>! This immediately results in redirect loops with most ssl redirect solutions given on the web since Nginx doesn't know it's being served through SSL.</p> <p> </p> <p>The easy solution, check the Cloudflare headers and redirect if it's not https:</p> <pre><code class="language-javascript">server { ... if ($http_x_forwarded_proto = "http") { return 301 https://$server_name$request_uri; } ... }</code></pre> <p> </p>

Get New Tutorials Delivered to Your Inbox

New tutorials will be sent to your Inbox once a week.

comments powered by Disqus