Welcome! Log In Create A New Profile

Advanced

Different FastCGI backend for /subdir: regex not matching

August 11, 2011 04:22AM
I have a virtual host, and for a certain subdirectory I want to use another fastcgi backend.

What I have now goes something like:
(...)
location ~ /subdir/ {
alias /var/www/otheraccount/public_html/;

# PHP FastCGI
location ^~ /subdir\/(.+)\.php {
return 504;
include /usr/pkg/etc/nginx/fastcgi_params;

fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/othervhost/public_html$fastcgi_script_name;

try_files $uri =502;
}
}

# PHP FastCGI
location ~ \.php {
include /usr/pkg/etc/nginx/fastcgi_params;

fastcgi_pass 127.0.0.1:9001;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/blah/public_html$fastcgi_script_name;

try_files $uri =403;
}
}

Ignore the try_files and bogus return, they're in place to try to trace what's happening where.

This is nginx 1.0.4, if it matters.

Basically, the problem is that the last try_files is triggered (I get a 403 requesting /subdir/index.php, and if I change that last try_files to 404 then I get a 404); Therefore I conclude the regex trying to catch php files under /subdir is not effective.

What would the proper regex be ?
I want it to catch /subdir/*.php, /subdir/subsub/*.php, /subdir/s/u/b.php, etc

On a related note, trying to access www.vhost.local/subdir (no trailing /) results in nginx trying to serve subdir from the original root (ie the alias isn't picked up); It may be a trivial question but I've run into this in the past. What is the correct way to catch both /subdir and /subdir/ requests?


I would very much appreciate a reply on this subject, as I've been struggling with this for hours. Regexes are not my strong point.

Thanks.
Subject Author Posted

Different FastCGI backend for /subdir: regex not matching

hugo August 11, 2011 04:22AM

Re: Different FastCGI backend for /subdir: regex not matching

Maxim Dounin August 11, 2011 06:48AM

Re: Different FastCGI backend for /subdir: regex not matching

hugo August 11, 2011 09:00AM

Re: Different FastCGI backend for /subdir: regex not matching

hugo August 11, 2011 09:02AM

Re: Different FastCGI backend for /subdir: regex not matching

hugo August 12, 2011 03:33AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 295
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready