Thanks, try_files "" =404 works indeed as long as the regexp location block contains the necessary alias. I.e. the original example modified like in:
server {
listen 8080 default_server;
root /usr/share/nginx/html;
autoindex on;
location /x/ {
alias /test/;
location ~ ^/x/test {
try_files "" =404;
}
}
}
does not work, while the following one with an extra alias works nicely:
server {
listen 8080 default_server;
root /usr/share/nginx/html;
autoindex on;
location /x/ {
alias /test/;
location ~ ^/x/(test.*) {
alias /test/$1;
try_files "" =404;
}
}
}
P.S.
This is indeed a very simplified config. However, even in this form it is useful as it reports directories matching ^/x/test as not found even with autoindex on inherited from the server context.