Last active
February 6, 2017 20:34
-
-
Save mudge/7dffb18b4746a291109ba756584dcb8e to your computer and use it in GitHub Desktop.
Handling Fastly TLS termination in nginx with map: http://nginx.org/en/docs/http/ngx_http_map_module.html
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
# Declares a new variable, $forwarded_scheme, that contains the URL scheme | |
# used by a user even if Fastly terminates your TLS connections. | |
# | |
# Will use the scheme extracted from the request URI by default or return | |
# "https" if the Fastly-SSL HTTP header is found. | |
map $http_fastly_ssl $forwarded_scheme { | |
default $scheme; | |
"1" "https"; | |
} | |
# And then elsewhere... | |
server { | |
server_name example.com; | |
return 301 $forwarded_scheme://www.example.com$request_uri; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment