Welcome! Log In Create A New Profile

Advanced

Nginx location - Distinguish requests by arguments or queries

February 25, 2020 07:05AM
Hello,

We have a case when we should permit different methods on the same location but different requests.

For location /test we should permit only POST, for /test?doc we should permit only GET methods.

Our config example:
----
location /test {
error_page 403 =405 /custom-error;

limit_except POST {
deny all;
}

proxy_pass http://test/in;
}
----

Map doesn't help us, it can't be used inside 'limit_except'. We also tried to use 'if' to pass a request to named location using 'try_files' but it also is not allowed inside 'if'.

Can't be used:
----
limit_except $method {
deny all;
}

if ($request_uri ~ \?doc) {
try_files @test-doc;
}
----

The question is, if there a way to implement this and how?

Thank you!
Subject Author Posted

Nginx location - Distinguish requests by arguments or queries

stmx38 February 25, 2020 07:05AM

Re: Nginx location - Distinguish requests by arguments or queries

Francis Daly February 25, 2020 12:08PM

Re: Nginx location - Distinguish requests by arguments or queries

Francis Daly February 26, 2020 03:50AM

Re: Nginx location - Distinguish requests by arguments or queries

stmx38 February 27, 2020 02:20PM

Re: Nginx location - Distinguish requests by arguments or queries

Francis Daly February 27, 2020 06:32PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 99
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready