[feature] Add skip_location directive to ngx_http_rewrite

Dmitrii Chekaliuk d.chekaliuk at invisilabs.com
Thu Jan 17 15:32:35 UTC 2013


Hmm, you pushed me to rethink this. Actually, the logic needed for my 
particular task could be done with IFs and BREAKs like this:

location / {
     if ($uri ~ ^/some/path) {
         if ($request_method ~ ^GET|HEAD$) {
             break;
             # config 1
         }

         if ($request_method = "PUT") {
             break;
             # config 2
         }
     }

     if ($uri ~ ^/some/path/subpath$) {
         # config 3
     }
}

But nested IFs need to be allowed for that purpose. I can't see any 
obstacles for this, as It seems like adding NGX_HTTP_SIF_CONF and 
NGX_HTTP_LIF_CONF to IF's type would be enough, though I'm not very 
familiar with nginx codebase to know for sure. Or there was some 
objective reason to disallow nesting?

--
Yours faithfully,
Dmitrii

On 17.01.2013 13:32, Nick Kew wrote:
> On 17 Jan 2013, at 10:07, Dmitrii Chekaliuk wrote:
>
>> Hi guys,
>>
>> I'm new to nginx-devel, so, please, take my apologies in case this question was already discussed and rejected. Nginx is awesome, but I think it lacks the flexibility of configuration selection, e.g. it can't throw away the selected config on demand within the rewrite phase to select another one without a need to actually rewrite URI. Think of Apache mod_rewrite's RewriteCond+RewriteRule, it would be great to have the ability to write something like this:
> I'm not sufficiently familiar with nginx config to comment on how it might work.
>
> But with Apache we implemented <if "expr …"> to do (among other things)
> exactly what you're asking for, in a saner manner than pseudo-programming
> with mod_rewrite.  Your suggestion looks like "IF foo GOTO bar", but wouldn't
> you prefer IF/ELSE/ENDIF with a similar structure to a Location block?
>



More information about the nginx-devel mailing list