1

I can't nest if and I don't have an and operator to use with if, so how would i un-nest this:

if ($AUTHENTICATED) {
    proxy_pass http://backend;
{
if (!$AUTHENTICATED) {
    if ($args ~ out=xml) {
        rewrite (.*)$ $1.xml break;
    }
    if ($args ~ out=csv) {
        rewrite (.*)$ $1.csv break;
    }
 }

1 Answer 1

2
if ($AUTHENTICATED) {
    proxy_pass http://backend;
    break;
}

if ($arg_out = xml) {
    rewrite ^ $uri.xml break;
}

if ($arg_out = csv) {
    rewrite ^ $uri.csv break;
}

but, please note: http://wiki.nginx.org/IfIsEvil

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .