The setup I'm going for is as follows: I want nginx to look for a file in the /test subdirectory, and if it's not there, serve it from it's normal uri. I figured this would be fairly straightforward with try_files. Here's the setup I came up with:
server {
listen 80;
server_name test-server;
location / {
root /opt/www;
index index.php;
try_files /test$uri $uri;
}
}
This half-works. If I go to http://test-server/something, and there is a /test/something file, it will serve the /test/something file. However, if there isn't a /test/something file, but there is a /something file, it will return a 500 Internal Server error. My best guess is that there's some kind of recursive looping going on, but I don't know what the alternative would be.
The last argument to try_files has to be a guaranteed file. $uri is not acceptable for this. Instead use
try_files /test$uri $uri =404;