Good evening,
~ What I would like to do ~
I need a default location block matching anything, location / {}
I guess, this block has its own root directory. it has to serve any static file and interpret any php files inside its document root or subfolders. (I set this up and it seams to works fine)
And here is where I need some help :(
…
Inside this same server block, I would like to host a php symphony application served when hitting mydomain.foo/panel/
area. So I added a ^~ /panel/
location (uri starts with /panel/)
My problem is that the try_files does not behave as I expect ( internal redirect to the last nested location in case uri do not match the nested location) . See code comments below.
~ My configuration as is … ~
upstream phpfcgi {
server unix:/var/run/php5-fpm.sock;
}
server {
listen 80;
server_name domain.tld;
## Default locations
location / {
root /home/me/sites/default/www;
index index.php;
location ~ \.php$ {
include fastcgi.conf;
fastcgi_pass phpfcgi;
}
location ~ /(.+) {
try_files $uri $1 =404;
}
}
## panel area
location ^~ /panel/ {
# Public files are located in sf/web sub-directory
alias /home/me/sites/sf/web/;
# Since uri starts with '/panel/', I expect NGINX to execute try_files as a last resort.
# if nested location do not match, and uri is not an existing file,
# shouldn't nginx do an internal redirect with the 2nd try_files argument
# and finally hit the nested location (triggering fastcgi_pass) ?
# But try_files is ignored and nginx falls back to "/" location above instead.
try_files $uri /panel/app_dev.php$is_args$args;
# FastCGIpass to upstream
location ~ (app_dev|config)\.php(/|$) {
try_files $fastcgi_script_name =404;
set $path_info $fastcgi_path_info;
fastcgi_param PATH_INFO $path_info;
include fastcgi.conf;
fastcgi_pass phpfcgi;
}
}
# Custom errors
error_page 403 404 =404 @null;
error_page 324 500 502 503 504 =500 @null;
location @null {
root /home/me/sites/_;
rewrite ^.+$ /$status.html break;
try_files $uri 444;
}
}
If my configuration is too clumsy, then how can I fulfill my requirements ? (default location with document root, and a special area serving my php application, on the same server) ?
NGINX documentation is getting better, but there still are things I do not understand in the request processing flow.
Any solution / suggestion / improvement ?
Thank you :)