如何关闭Web服务器目录遍历任意文件访问(含Tomcat\Apache\IIS\Nginx解决方案)

itlao6 资源分享 原创 工具&方法评论721字数 715阅读2分23秒阅读模式

服务器目录遍历是常见的Web服务器漏洞之一,本文给出各种Web服务器如何修改web服务器配置,以达到浏览器不能访问目录的目的;包含Tomcat\Apache\IIS\Nginx四种服务器解决方案

各种服务器修复流程都是一致的,可分为三个步骤:修改Web服务器主配置> 重启服务器> 检验/完成文章源自IT老刘-https://itlao6.com/9104.html

具体操作步骤如下:文章源自IT老刘-https://itlao6.com/9104.html

一、Tomcat 

  步骤1 进入tomcat下的web.xml配置文章源自IT老刘-https://itlao6.com/9104.html

vi  /usr/local/apache-tomcat-9.0.44/conf/web.xml文章源自IT老刘-https://itlao6.com/9104.html

  步骤2     将servlet下的true改为false文章源自IT老刘-https://itlao6.com/9104.html

如何关闭Web服务器目录遍历任意文件访问(含Tomcat\Apache\IIS\Nginx解决方案)

 步骤3     检验,在浏览器中访问tomcat下的目录,显示为404则修改成功文章源自IT老刘-https://itlao6.com/9104.html

如何关闭Web服务器目录遍历任意文件访问(含Tomcat\Apache\IIS\Nginx解决方案)

二、Apache

   步骤1 进入httpd.conf配置文件文章源自IT老刘-https://itlao6.com/9104.html

vi /etc/httpd/conf/httpd.conf文章源自IT老刘-https://itlao6.com/9104.html

   步骤2 将Indexes删除 (Indexes表示若当前目录没有index.html就会显示目录结构文章源自IT老刘-https://itlao6.com/9104.html

如何关闭Web服务器目录遍历任意文件访问(含Tomcat\Apache\IIS\Nginx解决方案)

   步骤3 重启Apache文章源自IT老刘-https://itlao6.com/9104.html

systemctl  restart  httpd文章源自IT老刘-https://itlao6.com/9104.html

三、IIS

   步骤1   进入IIS管理器文章源自IT老刘-https://itlao6.com/9104.html

如何关闭Web服务器目录遍历任意文件访问(含Tomcat\Apache\IIS\Nginx解决方案)

   步骤2 禁用目录浏览功能文章源自IT老刘-https://itlao6.com/9104.html

1)双击进入目录浏览文章源自IT老刘-https://itlao6.com/9104.html

如何关闭Web服务器目录遍历任意文件访问(含Tomcat\Apache\IIS\Nginx解决方案)

2)禁用目录浏览文章源自IT老刘-https://itlao6.com/9104.html

如何关闭Web服务器目录遍历任意文件访问(含Tomcat\Apache\IIS\Nginx解决方案)

   步骤3 重启网站文章源自IT老刘-https://itlao6.com/9104.html

如何关闭Web服务器目录遍历任意文件访问(含Tomcat\Apache\IIS\Nginx解决方案)

四、Nginx

   步骤 1 进入nginx.conf配置文件文章源自IT老刘-https://itlao6.com/9104.html

nginx安装目录下的conf目录下含有nginx.conf文件文章源自IT老刘-https://itlao6.com/9104.html

   步骤2 修改 autoindex on 将on改为 off文章源自IT老刘-https://itlao6.com/9104.html

如何关闭Web服务器目录遍历任意文件访问(含Tomcat\Apache\IIS\Nginx解决方案)

   步骤3 重启nginx服务.文章源自IT老刘-https://itlao6.com/9104.html

Windows中重启nginx服务:在nginx安装目录中执行以下命令

如何关闭Web服务器目录遍历任意文件访问(含Tomcat\Apache\IIS\Nginx解决方案)

注:若配置未生效可能是重启失败,这时 使用如下命令关闭进程,重新启动nginx

taskkill /f /t /im nginx.exe

如何关闭Web服务器目录遍历任意文件访问(含Tomcat\Apache\IIS\Nginx解决方案)
weinxin
我的微信公众号
微信扫一扫关注公众号,不定时更新
itlao6
  • 本文由 发表于 2022年 8月 11日 22:45:00
  • 转载请务必保留本文链接:https://itlao6.com/9104.html
评论  0  访客  0
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定