Hello!
On Thu, Jan 17, 2013 at 05:32:35PM +0200, Dmitrii Chekaliuk wrote:
> 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
> }
> }
What you need is something like this:
location / {
# not marked in your config
}
location /some/path {
# config 1, config 2 based on $request_method - either
# using if, or limit_except
}
location = /some/path/subpath {
# config 3
}
Note that nginx configuration is declarative in general, and you
may have better luck not trying to do imperative programming in it
with rewrite module directives.
See also this article with some more examples of how to convert
Apache rewrite rules into nginx configuration properly:
http://nginx.org/en/docs/http/converting_rewrite_rules.html
[...]
--
Maxim Dounin
http://nginx.com/support.html
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
On Thu, Jan 17, 2013 at 05:32:35PM +0200, Dmitrii Chekaliuk wrote:
> 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
> }
> }
What you need is something like this:
location / {
# not marked in your config
}
location /some/path {
# config 1, config 2 based on $request_method - either
# using if, or limit_except
}
location = /some/path/subpath {
# config 3
}
Note that nginx configuration is declarative in general, and you
may have better luck not trying to do imperative programming in it
with rewrite module directives.
See also this article with some more examples of how to convert
Apache rewrite rules into nginx configuration properly:
http://nginx.org/en/docs/http/converting_rewrite_rules.html
[...]
--
Maxim Dounin
http://nginx.com/support.html
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel