Nginx的位置,允许在不终止
问题描述:
我有以下规则:Nginx的位置,允许在不终止
location ~ /xmlrpc\.php {
deny all;
}
location ~ [^/]\.php(/|$) {
fastcgi...
}
一切工作正常,直到我需要让xmlrpc.php
一些地址。有没有什么办法可以让xmlrpc.php
没有所有其他php的重复规则?可能是想告诉这个位置只是为了允许否认不是用于实际处理。
更新:其实我知道包括变体。其他解决方案?
答
招PHP设置到外部文件php.conf
fastcgi...
,并将其纳入地方
location ~ /xmlrpc.php {
deny all;
include php.conf
}
location ~ [^/]\.php(/|$) {
include php.conf
}
答
你可以配置你的FastCGI在一个额外的文件,像
# /etc/nginx/fcgi_php.conf
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
和使用这个文件在你的位置:
location ~ [^/]\.php(/|$) {
include fcgi_php.conf
}
# allow/deny xmlrpc.php access
location ~ xmlrpc.php {
allow 192.168.1.0/24;
deny all;
include fcgi_php.conf;
}
不,这不是我所问的。我知道如何允许。我不知道如何避免将'fastcgi ...'加倍,因为每个部分允许部分拒绝的异常url。我需要像'跳'或'继续'。 –