Skip to content

Instantly share code, notes, and snippets.

@jrom
Created February 7, 2012 17:14
Show Gist options
  • Save jrom/1760790 to your computer and use it in GitHub Desktop.
Save jrom/1760790 to your computer and use it in GitHub Desktop.
nginx hack for multiple conditions
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;
}
@eladnava
Copy link

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