Last active
January 5, 2017 17:09
-
-
Save denwwer/ea08a529fdf979e4ca7c3e2b7c51dd12 to your computer and use it in GitHub Desktop.
nginx conf to redirect form http/www to https on AWS ELB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# set DOMAIN_NAME to your domain, example "google.com" | |
# server { | |
set $https_redirect 0; | |
if ($http_host = 'www.DOMAIN_NAME') { | |
set $https_redirect 1; | |
} | |
if ($http_x_forwarded_proto = 'http') { | |
set $https_redirect 1; | |
} | |
if ($http_x_forwarded_proto = '') { | |
set $https_redirect 1; | |
} | |
if ($http_user_agent ~ 'ELB-HealthChecker') { | |
set $https_redirect 0; | |
} | |
if ($https_redirect = 1) { | |
return 301 https://DOMAIN_NAME$request_uri; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment