我想限制访问(并且仅限于)http://mysite.com/protected.php使用 nginx。我可以尝试什么?目前,我设法做到了这一点,但 php 文件不再由 php-fpm 解释。
location ~ \.php($|/) {
location ~ ^/ws(_dev)?\.php {
auth_basic "User synchronisation webservice > please login";
auth_basic_user_file /home/symfony/instances/somesite/ws_access;
}
set $script $uri;
set $path_info "";
if ($uri ~ "^(.+\.php)(/.*)") {
set $script $1;
set $path_info $2;
}
add_header X-Response-Host somesite.com;
fastcgi_pass 127.0.0.1:8300;
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_FILENAME /home/symfony/instances/somesite/service/web$script;
fastcgi_param PATH_INFO $path_info;
fastcgi_param SCRIPT_NAME $script;
fastcgi_param SERVER_PORT "80";
}
答案1
您需要fastcgi_*
在新的location /protected.php
块中重复指令。