Skip to content

Instantly share code, notes, and snippets.

@mitchellh
Created May 18, 2011 19:15
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mitchellh/979302 to your computer and use it in GitHub Desktop.
Save mitchellh/979302 to your computer and use it in GitHub Desktop.
# This is a nginx config snippet showing how to inherit an http header
# or defaulting it to a specific value. This is useful because it allows
# upstream load balancers to set specific headers, but if they're missing
# the app LB will know how to default it.
# This will inherit the previously set X-Scheme variable, or otherwise
# default it to the current `$scheme`. Requires nginx 0.9.0+.
#
# Docs: http://wiki.nginx.org/HttpMapModule#map
map $http_x_scheme $x_scheme {
"" $scheme;
default $http_x_scheme;
}
server {
listen 80;
# Use the inherited-or-defaulted $x_scheme var
proxy_set_header X-Scheme $x_scheme;
# And go to the app server!
proxy_pass http://frontends;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment