Welcome! Log In Create A New Profile

Advanced

[feature] Add skip_location directive to ngx_http_rewrite

Dmitrii Chekaliuk
January 17, 2013 05:08AM
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:

location ~ ^/some/path$ {
if ($request_method !~* ^GET|HEAD$) { skip_location; }

# ...
}

location ~ ^/some/path$ {
# ...
}

to replicate mod_rewrite's:

RewriteCond %{REQUEST_URI} ^/some/path$
RewriteCond %{REQUEST_METHOD} ^GET|HEAD$ [NC]
RewriteRule ...

RewriteCond %{REQUEST_URI} ^/some/path$
RewriteRule ...

I know we could rewrite original URI with method added, like
$request_method/$uri, and make our location regexes aware of this, but
what if such a logic is needed only for some locations? So, I suggest
adding the before mentioned skip_location directive to the http_rewrite
module. There is a commit on GitHub with the results of my research:
https://github.com/lazyhammer/nginx/commit/88637c563f861a50cc8f6d029b1d2d8cf0c27e36

What do you think?

--
Yours faithfully,
Dmitrii

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[feature] Add skip_location directive to ngx_http_rewrite

Dmitrii Chekaliuk 995 January 17, 2013 05:08AM

Re: [feature] Add skip_location directive to ngx_http_rewrite

Nick Kew 507 January 17, 2013 06:34AM

Re: [feature] Add skip_location directive to ngx_http_rewrite

Dmitrii Chekaliuk 494 January 17, 2013 10:34AM

Re: [feature] Add skip_location directive to ngx_http_rewrite

Brian Akins 486 January 17, 2013 06:20PM

Re: [feature] Add skip_location directive to ngx_http_rewrite

Maxim Dounin 573 January 20, 2013 09:22PM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 189
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready