-
-
Save theY4Kman/5935315 to your computer and use it in GitHub Desktop.
nginx configuration which redirects based on the Host header. I use this in combination with a hosts file directing "myd" and "int" to localhost (or my workstation's IP if on a different computer) to allow cross-browser shortcuts to webapps not requiring a port. This means I can type "int/mypage" in Chrome, Firefox, IE, etc and be redirected to …
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
server { | |
if ($host = 'int') { | |
set $test I; | |
} | |
if ($host = 'myd') { | |
set $test M; | |
} | |
if ($remote_addr = '127.0.0.1') { | |
set $test '${test}L'; | |
} | |
if ($remote_addr != '127.0.0.1') { | |
set $test '${test}R'; | |
} | |
if ($test = IL) { | |
rewrite ^(.*)$ http://localhost:5050$1 break; | |
} | |
if ($test = IR) { | |
rewrite ^(.*)$ http://10.0.40.150:5050$1 break; | |
} | |
if ($test = ML) { | |
rewrite ^(.*)$ http://localhost:5051$1 break; | |
} | |
if ($test = MR) { | |
rewrite ^(.*)$ http://10.0.40.150:5051$1 break; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment