我有以下nginx位置块:
location /publish/domain.io.php { allow 127.0.0.1; deny all; } location ~\.php { try_files $uri =404; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_intercept_errors on; fastcgi_pass 127.0.0.1:9000; include /etc/nginx/fastcgi_params; }
问题是位置块/publish/domain.io.php
似乎没有执行。 我可以从任何主机调用php脚本domain.io.php
。
想法? 非常感谢。
使用=
位置前缀来确定完全匹配。 正如它在nginx文档中所写:“如果find完全匹配,则search终止。”
所以,你的位置应该是这样的:
location = /publish/domain.io.php { 允许127.0.0.1; 否认一切; #给403 }
要么
location = /publish/domain.io.php { 内部; #404 }