Created
February 7, 2012 17:14
-
-
Save jrom/1760790 to your computer and use it in GitHub Desktop.
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; | |
} |
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!
Awesome!!!! Thanks!
If somebody needs an explanation what the code does is it sequentially appends different letters to one variable.
When all the letters are present that means that all the required conditions have been met.
This works great!
I recommend initializing the $test
variable outside and above all the conditional statements to avoid endless using uninitialized "test" variable
errors piling up in /var/log/nginx/error.log
as follows:
set $test "";
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@songsfromthewood Actually no, yours does not match "test.teambox.com" while the original post does.