I'm serving webapps out of arbitrary subfolders on a domain. i.e.
example.com/app-one (with example.com/app-one/page served by app-one)
example.com/folder/app-two (with example.com/folder/app-two/page served by app-two)
I have a nginx config that works just fine for the root level, but I'm a little stumped on how to handle subfolders. I could make location /app-one
blocks, of course, but we have dozens of these and we'd like to avoid having to expliticly specify each one.
Is there any way to get try_files
to essentially recurse up the folder structure until it hits an index.php file?
server {
server_name example.com
location / {
root /srv/web/example.com;
index index.php index.html;
try_files $uri $uri/ /index.php?q=$q&$args;
}
# pass *.php files to the PHP tier
location ~ \.php$ {
root /srv/web/example.com;
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass php:9000;
}
}
Your first location statement should care for those requests inside subfolders.
I'm wondering what's on nginx's logfiles.