Thanks again for detailed explanation. Now I almost grasped how try_files works. "Almost" because I still do not see why the following does not work:
server {
listen 8080 default_server;
root /usr/share/nginx/html;
autoindex on;
location /x/ {
alias /test/;
location ~ ^/x/(test.*) {
try_files $1 =404;
}
}
}
For localhost/x/test.html $1 will be test.html. I suppose $document_root should be /test/ as it was set with the alias in the outer location so try_files should try to check for existing /test/test.html . However, nginx still reports 404. Why it is so?