-
-
Save v1nc3ntlaw/6696d0bfa9069f9c0a8142fab7fc0c78 to your computer and use it in GitHub Desktop.
Force Redirect HTTP to HTTPS on nginx behind ELB
This file contains hidden or 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
# redirect http to https | |
set $redirect ""; | |
if ($http_x_forwarded_proto != 'https') { | |
set $redirect "1"; | |
} | |
if ($http_user_agent !~* ELB-HealthChecker) { | |
set $redirect "${redirect}1"; | |
} | |
if ($http_host ~ "your-nifty-domain.com") { | |
set $redirect "${redirect}1"; | |
} | |
if ($redirect = "111") { | |
rewrite ^ https://$host$request_uri? permanent; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment