try_files and a nested location regexp

igorb nginx-forum at nginx.us
Thu Oct 16 12:42:26 UTC 2014


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?

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,254033,254047#msg-254047



More information about the nginx mailing list