nginx - php-fpm: access restrictions for some php pages
m.desantis
nginx-forum at nginx.us
Thu Jan 31 11:53:40 UTC 2013
You mean like this?
location ~ ^\/some\/path\/(.*\.php)$ {
alias /some/path;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
# # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
#
# # With php5-cgi alone:
# fastcgi_pass 127.0.0.1:9000;
# # With php5-fpm:
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
# Changes due to the alias declaration
fastcgi_param SCRIPT_FILENAME $document_root/$1;
fastcgi_param SCRIPT_NAME /$1;
allow 10.0.0.0/24;
deny all;
}
But now restriction rules are applied to all PHP files; instead I want to
apply them just to some PHP files; should I use a nested location? something
like this?
location ~ ^\/some\/path\/(.*\.php)$ {
alias /some/path;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
# # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
#
# # With php5-cgi alone:
# fastcgi_pass 127.0.0.1:9000;
# # With php5-fpm:
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
# Changes due to the alias declaration
fastcgi_param SCRIPT_FILENAME $document_root/$1;
fastcgi_param SCRIPT_NAME /$1;
location ~ \/phpinfo\.php$ {
allow 10.0.0.0/24;
deny all;
}
}
Posted at Nginx Forum: http://forum.nginx.org/read.php?2,235769,235775#msg-235775
More information about the nginx
mailing list