Skip to content

Instantly share code, notes, and snippets.

@pragnesh
Forked from jrom/nginx.conf
Last active July 14, 2016 10:16
Show Gist options
  • Save pragnesh/d3c054a7650339769402d9dc06fd0f52 to your computer and use it in GitHub Desktop.
Save pragnesh/d3c054a7650339769402d9dc06fd0f52 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;
}
for or condition
set $my_var 0;
if ($host = 'domain.com') {
set $my_var 1;
}
if ($host = 'domain2.com') {
set $my_var 1;
}
if ($my_var = 1) {
rewrite ^/(.*)$ http://www.domain.com/$1 permanent;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment