我的配置有问题,我使用的是 nginx/1.10.3, php5-fpm。
这是我的默认配置位置:
location / {
try_files $uri $uri/ =404;
allow 1.2.3.4; #my ip
allow 127.0.0.1;
allow 11.22.33.44; #server ip
deny all;
}
当我尝试访问 11.22.33.44 时,我有一个 403 Forbidden:
2017/03/08 16:30:25 [error] 340#340: *3 access forbidden by rule, client: 1.2.3.4, server: _, request: "GET / HTTP/1.1", host: "11.22.33.44"
谢谢你的帮助 !
解决,解决方案:
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
allow 127.0.0.1;
allow 1.2.3.4; #my ip
deny all;
}