Skip to content

Instantly share code, notes, and snippets.

Created July 5, 2013 15:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/5935312 to your computer and use it in GitHub Desktop.
Save anonymous/5935312 to your computer and use it in GitHub Desktop.
nginx configuration for host redirects. Allows me to type "int" or "myd" on any browser on my workstation or otherwise (as long as the entries pointing to my workstation are in the hosts file), and it'll redirect me to the correct address and port for that app.
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