Is there a better way to do this? I can't find a way to nest or apply boolean operators to conditions in nginx.
Basically if there is a cookie set(non-anonymous user) we want to hit the server. If the cookie is not set and the file exists we want to server the file otherwise hit the server.
set $test "D";
if ($http_cookie ~* "session" ) {
set $test "${test}C";
}
if (-f $request_filename/index.html$is_args$args) {
set $test "${test}F";
}
if ($test = DF){
rewrite (.*)/ $1/index.html$is_args$args?
break;
}
if ($test = DCF){
proxy_pass http://django;
break;
}
if ($test = DC){
proxy_pass http://django;
break;
}
if ($test = D){
proxy_pass http://django;
break;
}
Not sure if much better, but avoided using things considered unsafe in the if statements.