Skip to content

Instantly share code, notes, and snippets.

Created February 7, 2012 17:14
Star You must be signed in to star a gist
What would you like to do?
nginx hack for multiple conditions
if ($request_uri = /) {
set $test A;
if ($host ~* {
set $test "${test}B";
if ($http_cookie !~* "auth_token") {
set $test "${test}C";
if ($test = ABC) {
Copy link

this is awesome!

Copy link

GoodJob commented Mar 17, 2021

Need explanation.... what actually this does:
if ($host ~* {
set $test "${test}";
Does it takes "this" or what? Thanks!

How to write this condition?

if ($host * {
set $subdomain_name = ?;


Copy link

lordspace commented Jun 26, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment