配置文件中静态资源文件禁止通过目录查看

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

优先级: = > ^~ > ~ ~*

最新文章

  1. HTML标签显示在页面上
  2. keepalived衡环境搭建
  3. 你离月薪30K还差哪些?
  4. 【VirtualBox】端口转发,ssh
  5. 毕老师的Editplus
  6. 当可以设置src时,不必发ajax请求,如果没有参数设置src即可
  7. UVa 11292 - Dragon of Loowater(排序贪心)
  8. SolrCloud 5.2.1 installation and configuration
  9. 对面试题(剑指offer)产生的一些思考。
  10. php函数的使用
  11. springboot mybatis redis 二级缓存
  12. Javascript - ExtJs - XTemplate组件
  13. 使用shape设置android控件只有部分边框有颜色
  14. Jmeter(二十六)Jmeter-Question之“集成Jenkins”
  15. "//./root/CIMV2" because of error 0x80041003. Events cannot be delivered through this filter until the problem is corrected.
  16. Mina的服务器
  17. C# GridView 给某行或某列绑定点击事件和鼠标事件
  18. free 和delete 把指针怎么啦?
  19. Haskell中cabal install glib遇到的问题
  20. hdu5012 圆环相交面积

热门文章

  1. webrtc 拥塞控制相关
  2. Telnet登陆网络设备执行命令脚本
  3. gorm去重查询 iris框架
  4. docker-compose 搭建 redis 集群
  5. 看K线学炒股(8.9)
  6. vim中的命令行 %! 是啥意思?
  7. PL/SQL Initialization error Could not initialize 问题
  8. 复制 GUI 状态
  9. idea var 总是有final
  10. 3d-force-graph使用及相关设置