Created
April 19, 2018 10:35
-
-
Save foxted/3a2e57f23a6720000406841d5fd2f75e to your computer and use it in GitHub Desktop.
Force https on EC2 behind ALB except Healthchecks
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
server { | |
# If traffic is http | |
if ($http_x_forwarded_proto != 'https') { | |
set $force_https "A"; | |
} | |
if ($http_user_agent ~ 'ELB-HealthChecker/2.0') { | |
set $force_https "${force_https}B"; | |
} | |
if ($force_https = 'A') { | |
return 301 https://$host$request_uri; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment