Welcome! Log In Create A New Profile

Advanced

Weird location choice

B.R.
November 18, 2015 03:20PM
WIth the following configuration:
server {
listen 80;
listen [::]:80;

location / {
location ~* "^/[[:alnum:]]+$" {
default_type text/plain;
return 200 "KO";
}
}

location ~* "^/test" {
default_type text/plain;
return 200 "OK";
}
}

​I noticed that calling example.org/test returns KO.​

The location docs
<http://nginx.org/en/docs/http/ngx_http_core_module.html#location> say the
longest prefix match ('/') is remembered then regex are checked. Since the
'test' regex is on the same level, you would expect higher precedence for
it compared to the embedded 'alnum' one, which is one level deeper.

If secondary-level regex locations have the same priority as others, you
are basically doomed trying to prioritize regex locations between each
others using prefix locations at an upper-level.

​Where am I wrong?​
---
*B. R.*
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Weird location choice

B.R. November 18, 2015 03:20PM

Re: Weird location choice

Maxim Dounin November 18, 2015 03:44PM

Re: Weird location choice

B.R. November 18, 2015 04:26PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 168
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