need help configuring this location directive
dfelicia
nginx-forum at nginx.us
Wed Apr 11 19:46:01 UTC 2012
I've been reading about how nginx matches requests - most specific to
least, then regex in the order they are listed. For fastcgi, though, all
of the tutorials suggest something like:
location ~ \.php$ {
try_files $uri =404;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME
$document_root$fastcgi_script_name;
fastcgi_pass yada yada;
}
What if I want/need to run fastcgi from a location that nginx matches
before this regex, though? Do I have to repeat the whole fastcgi config
in that block, or is there a more elegant way?
For example:
root /srv/http/example.com
location = /favicon.ico {
log_not_found off;
access_log off;
}
# /~user/private w/basic auth
location ~ ^/~(.+?)/private(/.*)?$ {
auth_basic "Restricted";
auth_basic_user_file htpasswd;
alias /home/$1/private_html$2;
index index.html index.htm;
autoindex on;
}
# /~user
location ~ ^/~(.+?)(/.*)?$ {
alias /home/$1/public_html$2;
index index.html index.htm;
autoindex on;
}
# serve static files directly
location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt)$ {
access_log off;
expires 30d;
}
# I have no idea what this does
location ~ \..*/.*\.php$ {
return 403;
}
# fastcgi
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
#NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME
$document_root$fastcgi_script_name;
fastcgi_pass phpcgi;
}
So in the above example, what if I want to serve php from ~/user ?
Posted at Nginx Forum: http://forum.nginx.org/read.php?2,225187,225187#msg-225187
More information about the nginx
mailing list