nginx hack for multiple conditions
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
if ($request_uri = /) { | |
set $test A; | |
} | |
if ($host ~* teambox.com) { | |
set $test "${test}B"; | |
} | |
if ($http_cookie !~* "auth_token") { | |
set $test "${test}C"; | |
} | |
if ($test = ABC) { | |
proxy_pass http://teambox-cms.heroku.com; | |
break; | |
} |
awesome ! 666666
Nice. Thanks
Awesome man, thanks.
Seems, you are not familiar with map, or do not like it. More short and elegant:
":" is used just like delimiter, you can use any other symbol not used in checked variables.
map "$request_uri:$host:$http_cookie" $test { default 0; "/:teambox.com:auth_token" 1; } server { if ( $test ) { proxy_pass http://teambox-cms.heroku.com; break; } }
@songsfromthewood Actually no, yours does not match "test.teambox.com" while the original post does.
this is awesome!
Need explanation.... what actually this does:
if ($host ~* teambox.com) {
set
}
Does it takes "this".teambox.com or what? Thanks!
How to write this condition?
if ($host *.teambox.com) {
set $subdomain_name = ?;
}
Thanks!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You truly are the king of kings