location 禁止多目录
[root@web01 default]# mkdir cron templates
[root@web01 default]# tree
.
├── cron
└── templates directories, files
[root@web01 default]# tree
.
├── cron
│ └── index.html
└── templates
└── index.html directories, files
[root@web01 default]# cat cron/index.html
i am cron
[root@web01 default]# cat templates/index.html
i am templates
[root@web01 default]#
[root@web01 templates]# curl http://192.168.1.24/cron/
i am cron
[root@web01 templates]# curl http://192.168.1.24/templates/
i am templates
[root@web01 templates]# 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+)/(.+)/ /$/$ last;
location ~ ^/(cron|templates)/ {deny all;break;}
[root@web01 templates]# curl http://192.168.1.24/cron/
<html>
<head><title> Forbidden</title></head>
<body bgcolor="white">
<center><h1> Forbidden</h1></center>
<hr><center>nginx/1.4.</center>
</body>
</html>
[root@web01 templates]# curl http://192.168.1.24/templates/
<html>
<head><title> Forbidden</title></head>
<body bgcolor="white">
<center><h1> Forbidden</h1></center>
<hr><center>nginx/1.4.</center>
</body>
</html>
location 禁止多目录的更多相关文章
- 禁止指定目录执行php文件
我们设置网站权限的时候,有些目录不得不设置让http服务器有写入权限,这样安全隐患就来了.比如discuz x2的 data目录,这个必须要有写入限,论坛才能正常运行,但有的黑客可能就会利用这个目录上 ...
- Nginx技巧——Nginx/Apache下禁止指定目录运行PHP脚本(转自运维之美)
网站程序的上传目录通常是不需要PHP执行解释权限,通过限制目录的PHP执行权限可以提网站的安全性,减少被攻击的机率. 下面和大家一起分享下如何在Apache和Nginx禁止上传目录里PHP的执行权限. ...
- Nginx/Apache下如何禁止指定目录运行PHP脚本
下面和大家一起分享下如何在Apache和Nginx禁止上传目录里PHP的执行权限. Apache下禁止指定目录运行PHP脚本 在虚拟主机配置文件中增加php_flag engine off指令即可,配 ...
- tomcat中如何禁止列目录下的文件
tomcat中如何禁止列目录下的文件在{tomcat_home}/conf/web.xml中,把listings参数设置成false即可,如下: <servlet> <servlet ...
- nginx禁止访问目录中可执行文件
某些网站系统需要用户上传图片等文件到某些目录下,难免程序有些漏洞,导致用户上传了php.cgi等等可执行的文件,导致网站陷入非常为难的境地. 此时我们可以通过nginx来禁止用户访问这些目录下的可执行 ...
- 禁止apache显示目录索引的常见方法(apache禁止列目录)
禁止Apache显示目录索引,禁止Apache显示目录结构列表,禁止Apache浏览目录,这是网上提问比较多的,其实都是一个意思.下面说下禁止禁止Apache显示目录索引的常见的3种方法. 要实现禁止 ...
- 禁止apache显示目录索引 apache禁止列目录
禁止Apache显示目录索引的常见的3种方法. 要实现禁止Apache显示目录索引,只需将Option中的Indexes去掉即可. 禁止Apache显示目录索引,禁止Apache显示目录结构列表,禁止 ...
- location 将跟目录下某个文件夹指向2级目录
例如: /caffespressos/指向/web01/caffe/ [root@web01 default]# tree web01/ web01/ └── caffe └── index.html ...
- location 将多级目录下的文件转成一个文件
/ck-135-201-7142.html 指向/ck/135/201/7142.html [root@web01 www]# cat /app/server/nginx/conf/rewrite/d ...
随机推荐
- [转] Markdown
转自 https://en.wikipedia.org/wiki/Markdown#Example 英文版本 - http://daringfireball.net/projects/markdown ...
- Django文档学习
文档位置:https://docs.djangoproject.com/zh-hans/2.1/
- TYVJ-P1864 守卫者的挑战 题解
P1864 [Poetize I]守卫者的挑战 时间: 1000ms / 空间: 131072KiB / Java类名: Main 描述 打开了黑魔法师Vani的大门,队员们在迷宫般的路上漫无目的地搜 ...
- Epplus 设置excel 页边距 及多文件合并
1:使用epplus合并多个excel文件到同一excel的不同sheet页中 private static bool MergeExcel(string _stFilePath, List<s ...
- 数学图形(1.25)cassini曲线
通过这种曲线可以看到一种由8到0的过度 相关软件参见:数学图形可视化工具,使用自己定义语法的脚本代码生成数学图形.该软件免费开源.QQ交流群: 367752815 #http://www.mathcu ...
- 每日一小练——Armstrong数
上得厅堂.下得厨房,写得代码,翻得围墙,欢迎来到睿不可挡的每日一小练! 题目:Armstrong数 内容: 在三位的正整数中,比如abc.有一些能够满足a^3+b^3+c^3=abc的条件,也就是说各 ...
- 依据硬件设备配置高性能的Nginx
Nginx的高级配置会涉及硬件,假设配置不好,会直接让性能下降好多好多. 我这里总结一下,怎样依据server的硬件设备来配置Nginx. 见下图: 低訪问量的网络,能够这样配置. 标准的网络訪问量, ...
- BlazeMeter+Jmeter 搭建接口测试框架
转载:http://www.sohu.com/a/133218497_575744 关于接口测试,笔者认为其难点分别在如下几方面:接口参数的获取和输入.测试数据的准备.场景的串联.测试结果的断言. 接 ...
- (剑指Offer)面试题4:替换空格
题目: 请实现一个函数,把字符串中的每个空格替换成“%20”,例如输入“We are happy”,则输出“We%20are%20happy”. 思路: 背景: 在网络编程中,如果URL参数中含有特殊 ...
- Nginx安装部署(反向代理与负载均衡)
一.下载安装Nginx(本文环境为windows xp 32bit环境) 下载地址:http://files.cnblogs.com/likehua/nginx-1.0.11.zip 解压nginx- ...