<div dir="ltr"><div class="gmail_default" style="font-size:small;color:rgb(51,51,153)">WIth the following configuration:<br>server {<br>    listen      80;<br>    listen      [::]:80;<br><br>    location / {<br>        location ~* "^/[[:alnum:]]+$" {<br>            default_type text/plain;<br>            return 200 "KO";<br>        }<br>    }<br><br>    location ~* "^/test" {<br>        default_type text/plain;<br>        return 200 "OK";<br>    }<br>}<br><br clear="all"></div><div class="gmail_default" style="font-size:small;color:rgb(51,51,153)">​I noticed that calling <a href="http://example.org/test">example.org/test</a> returns KO.​<br><br></div><div class="gmail_default" style="font-size:small;color:rgb(51,51,153)"><a href="http://nginx.org/en/docs/http/ngx_http_core_module.html#location">The <span style="font-family:monospace,monospace">location</span> docs</a> 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.<br><br></div><div class="gmail_default" style="font-size:small;color:rgb(51,51,153)">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.<br></div><br><div class="gmail_default" style="font-size:small;color:rgb(51,51,153)">​Where am I wrong?​</div><div><div class="gmail_signature"><font size="1"><span style="color:rgb(102,102,102)">---<br></span><b><span style="color:rgb(102,102,102)">B. R.</span></b><span style="color:rgb(102,102,102)"></span></font></div></div>
</div>