Skip to content

Instantly share code, notes, and snippets.

@zahna
Last active February 11, 2020 21:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zahna/649b634048d758f513a6cd9925c5c61b to your computer and use it in GitHub Desktop.
Save zahna/649b634048d758f513a6cd9925c5c61b to your computer and use it in GitHub Desktop.
nginx proxy to different local backend sites, depending on a variable
map $http_x_forwarded_for $backend_site {
~^[6] www1.zahna.com;
default www2.zahna.com;
}
server {
listen 80;
listen 443 ssl;
server_name dfas78dsf9sa.cloudfront.net;
access_log /dev/null;
location / {
proxy_set_header Host $backend_site;
proxy_set_header X-Forwarded-Host $host;
proxy_pass http://127.0.0.1;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment