我试图拒绝除一个 IP 之外的所有外部世界访问我们的所有 PHP 脚本。
location / {
deny all;
allow <one-ip-address>;
error_page 403 goodpage.php;
try_files $uri $uri/ =404;
}
location ~ \.php$ {
deny all;
allow <one-ip-address>;
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
location /goodpage.php {
allow all;
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
但是,无论我做什么,我总是最终限制所有 *.php 或不限制任何内容。设置是 Ubuntu 16.04、Nginx 1.10.0,在此先致谢。