实际场景:
location /admin/
{
allow 192.168.211.152;
allow 127.0.0.1;
deny all;
}
测试
curl -x192.168.211.152:80 -I test.com/lsx/
HTTP/1.1 200 OK
curl -x127.0.0.1:80 -I test.com/lsx/
HTTP/1.1 200 OK
可以匹配正则
上传目录禁止解析php。首先解析php
location ~ .(upload|image)/..php$
{
deny all;
}
测试:
curl -x127.0.0.1:80 test.com/upload/index.php -I
HTTP/1.1 403 Forbidden
本文转自 虾米的春天 51CTO博客,原文链接:http://blog.51cto.com/lsxme/2057650,如需转载请自行联系原作者