假如我的站点后台地址为: http://www.abc.net/admin.php 那么我想限制只有个别ip可以访问后台,那么需要在配置文件中增加:



location ~ .*admin.* {
allow 1.1.1.1;
allow 12.12.12.0/24;
deny all;
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass unix:/tmp/php-fcgi.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /data/www$fastcgi_script_name;
}
}


需要注意的是,在这个location下也得加入php解析相关的配置,否则php文件无法解析。