Created
April 20, 2017 10:10
-
-
Save herecydev/d804be07f0a2909bbe88827fc7395500 to your computer and use it in GitHub Desktop.
Dynamic resolver and proxy pass for nginx
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
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