nginx - can a hyphen in a prefix match confuse try_files?
Your configuration
location /my-app {
root /usr/share/nginx/html/my-app;
}
makes nginx look for files in /usr/share/nginx/html/my-app/my-app
directory. This is because nginx appends the normalized URI in the location
to end of path specified in root
.
If you want to serve /usr/share/nginx/html/my-app/test.html
when requesting http://example.com/my-app/test.html
, then your configuration needs to be:
location /my-app {
root /usr/share/nginx/html;
try_files $uri $uri.html $uri/ /index.html =404;
}