2017-03-08 61 views
0

我的配置有问题,我使用nginx/1.10.3,php5-fpm。NGINX限制I.P不工作

这是我的默认配置文件位置:

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:

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; 
} 
+0

什么是你希望它做什么? –

+0

@RichardSmith感谢您的回复,我只想在我的家庭IP(1.2.3.4)的位置/例如!这是为了测试我的应用程序。 (如果你有另一个想法来测试我的网站没有人可以访问它?我拿)!否则,我添加一个robots.txt来不索引该网站 – Daphyduck

+0

但是'/'应该返回的URI是什么?例如。 'index.php'或'index.html'? –

回答

0

检查你的.conf文件,确保自动索引打开,否则会有这个错误

autoindex on;