Nginx location - Distinguish requests by arguments or queries
Francis Daly
francis at daoine.org
Thu Feb 27 23:31:14 UTC 2020
On Thu, Feb 27, 2020 at 02:20:45PM -0500, stmx38 wrote:
Hi there,
> 1. "~*" to be "~^"
> The first one looks like Nginx regexp we can use for locations, but the
> second one not (^~):
"map" is documented at http://nginx.org/r/map
"~" means "this arg is a regex, not a string". "~*" means "and that regex
is case-insensitive". The rest of the argument is the regex; in that,
"^" means "match the start of the string".
So "~^GET/test" in this case will match all GET requests that start with
"/test". "~GET/test" would also match any requests that include the
8-character sting GET/test, which is probably not what you want.
> 2. It seems that the order of records in map is important. We pass required
> queries with args, we block then all queries with args and allow without
> args a then default value is applied. Maybe you can provide more details
> here.
Yes, the order is important. Per the docs: the first matching regex is
the regex that counts.
So - if you have some things which are subsets of some other things,
you must put the more specific ones earlier in the config list.
Good luck with it,
f
--
Francis Daly francis at daoine.org
More information about the nginx
mailing list