[英]Block apc.php file in nginx
I am trying to block the apc.php file on my webserver. 我正在尝试阻止Web服务器上的apc.php文件。 If do the following it works but I am thinking there is a better way to do this and put the deny/allow rule below the general location ~ .php$ block. 如果执行以下操作,则可以,但是我在想有一种更好的方法,将“拒绝/允许”规则放在常规位置〜.php $块下面。 It doesnt seem right to have to have two blocks with the fastcgi params. 在fastcgi参数中必须具有两个块似乎并不正确。
#Block to apc.php
location ~ /apc.php {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
allow 192.168.3.0/24;
deny all;
}
# use fastcgi for all php files
location ~ \.php$
{
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
Since "deny" not allowed in if statement, you can use nested location like location / { location /uri/ {} }
, however, it is not encouraged in Nginx manual: 由于if语句中不允许使用“ deny”,因此您可以使用诸如location / { location /uri/ {} }
类的嵌套位置,但是,在Nginx手册中不建议这样做:
"While nested locations are allowed by the configuration file parser, their use is discouraged and may produce unexpected results." “虽然配置文件解析器允许嵌套位置,但不鼓励使用嵌套位置,并且可能产生意外结果。”
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.