Skip to content

Instantly share code, notes, and snippets.

@herecydev
Created April 20, 2017 10:10
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 herecydev/d804be07f0a2909bbe88827fc7395500 to your computer and use it in GitHub Desktop.
Save herecydev/d804be07f0a2909bbe88827fc7395500 to your computer and use it in GitHub Desktop.
Dynamic resolver and proxy pass for nginx
http {
resolver 127.0.0.11 valid=1s;
server {
listen 80;
set $foo "http://foo:80";
set $bar "http://bar:80";
location /foo/ {
rewrite ^/foo/(.*) /$1 break;
proxy_pass $foo;
}
location /bar/ {
rewrite ^/bar/(.*) /$1 break;
proxy_pass $bar;
}
}
}
// Wanting http://localhost:80/foo/controller => http://foo:80/controller
// Wanting http://localhost:80/bar/controller => http://bar:80/controller
// Observed (404) => http://localhost:80/controller
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment