location 禁止以/data开头的文件

 

[root@web01 default]# tree data/
data/
└── index.html

0 directories, 1 file
[root@web01 default]# cat data/index.html 
this is data!!!!
[root@web01 default]# curl http://192.168.1.24/data/
this is data!!!!

 

[root@web01 default]# cat /app/server/nginx/conf/rewrite/default.conf 
#rewrite ^/index\.html /index.php last;
#if (!-e $request_filename) rewrite ^/(.*)$ index.php last;
#if (!-e $request_filename) {rewrite ^/(.*)$ /index.php last;}
#if (!-e $request_filename) {return 404;}
#if ($http_user_agent ~ Firefox) {rewrite ^(.*)?$ /nginx-Firefox/$1 break;}
#if ($http_user_agent ~ MSIE) {rewrite ^(.*)$ /nginx-MSIE/$1 break;}
#rewrite ^/(\d+)/(.+)/ /$2/$1 last;
#location ~ ^/(cron|templates)/ {deny all;break;}
location ~ ^/data {deny all;}
[root@web01 default]# /app/server/nginx/sbin/nginx -s reload
[root@web01 default]# curl http://192.168.1.24/data/
<html>
<head><title>403 Forbidden</title></head>
<body bgcolor="white">
<center><h1>403 Forbidden</h1></center>
<hr><center>nginx/1.4.4</center>
</body>
</html>

 

posted @ 2016-08-02 10:04  bass  阅读(362)  评论(0编辑  收藏  举报