Nginx系列---【配置文件中静态资源文件禁止通过目录查看】
2024-10-21 17:39:37
配置文件中静态资源文件禁止通过目录查看
1.问题
nginx作为文件服务器时,默认是可以通过目录路径查看该目录下的所有文件的,这样很不安全,容易造成静态资源泄露。
2.方案
location /images {
autoindex off;
autoindex_exact_size off;
autoindex_localtime on;
alias /home/admin/fileupload;
}
- autoindex on; 显示整个目录(包括文件夹和文件),off不显示;
- autoindex_exact_size off; 默认为on,单位是bytes; 改为off后,单位是kB或者MB或者GB;
- autoindex_localtime on; 默认为off,显示的文件时间为GMT时间。
3.扩展-location匹配规则
~
正则匹配, 区分大小写~*
正则匹配, 不区分大小写^~
精确匹配, 如果该选项匹配,只匹配该选项,不匹配别的选项=
精确匹配, 这个不匹配其他人还有机会@
定义一个命名的 location,使用在内部定向时,例如 error_page, try_files
优先级: = > ^~ > ~ ~*
最新文章
- HTML标签显示在页面上
- keepalived衡环境搭建
- 你离月薪30K还差哪些?
- 【VirtualBox】端口转发,ssh
- 毕老师的Editplus
- 当可以设置src时,不必发ajax请求,如果没有参数设置src即可
- UVa 11292 - Dragon of Loowater(排序贪心)
- SolrCloud 5.2.1 installation and configuration
- 对面试题(剑指offer)产生的一些思考。
- php函数的使用
- springboot mybatis redis 二级缓存
- Javascript - ExtJs - XTemplate组件
- 使用shape设置android控件只有部分边框有颜色
- Jmeter(二十六)Jmeter-Question之“集成Jenkins”
- ";//./root/CIMV2"; because of error 0x80041003. Events cannot be delivered through this filter until the problem is corrected.
- Mina的服务器
- C# GridView 给某行或某列绑定点击事件和鼠标事件
- free 和delete 把指针怎么啦?
- Haskell中cabal install glib遇到的问题
- hdu5012 圆环相交面积