Apache httpd 目录列表禁用配置(options indexes)
2017-11-06 20:34
441 查看
Apache httpd服务器在缺省的情况下,开启了基于目录列表的访问,这是一个存在安全隐患的问题,因此可以关闭这个功能。在Apache 2.4的版本中,不在支持使用-indexes来配置,需要注释该功能。本文对此给出演示,供大家参考。
依旧可以访问,不过此时为apache的缺省欢迎页面
一、缺省情况目录列表可查看示例
当前环境 [root@centos7-web ~]# more /etc/redhat-release CentOS Linux release 7.2.1511 (Core) [root@centos7-web ~]# apachectl -v Server version: Apache/2.4.6 (CentOS) Server built: Nov 19 2015 21:43:13 为站点添加index.html页面 # echo "This is a apache test index page" > /var/www/html/index.html [root@centos7-web ~]# curl http://localhost This is a apache test index page 移除index.html [root@centos7-web ~]# mv /var/www/html/index.html /var/www/html/index.tmp
依旧可以访问,不过此时为apache的缺省欢迎页面
移除apache欢迎页面 [root@centos7-web ~]# mv /etc/httpd/conf.d/welcome.conf /etc/httpd/conf.d/welcome.conf.bk [root@centos7-web ~]# cp /usr/share/backgrounds/* /var/www/html/.
[root@centos7-web ~]# grep -Ev "^$|^#|*#" /etc/httpd/conf/httpd.conf >/etc/httpd/conf/httpd.conf.tmp [root@centos7-web ~]# cp /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf.1106 [root@centos7-web ~]# mv /etc/httpd/conf/httpd.conf.tmp /etc/httpd/conf/httpd.conf mv: overwrite ‘/etc/httpd/conf/httpd.conf’? yes
二、关闭options 中Indexes(关闭文件列表)
[root@centos7-web ~]# vim /etc/httpd/conf/httpd.conf [root@centos7-web ~]# grep "Indexes" -B1 -A3 /etc/httpd/conf/httpd.conf 查看修改后的结果 <Directory "/var/www/html"> # Options Indexes FollowSymLinks ##注释该行 AllowOverride None Require all granted </Directory> [root@centos7-web ~]# systemctl reload httpd [root@centos7-web ~]# curl http://localhost <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <html><head> <title>403 Forbidden</title> </head><body> <h1>Forbidden</h1> <p>You don't have permission to access / on this server.</p> </body></html>
三、关闭FollowSymLinks(关闭访问符号链接文件)
[root@centos7-web ~]# ln -sv /etc/redhat-release /var/www/html/redhat-release.html ‘/var/www/html/redhat-release.html’ -> ‘/etc/redhat-release’ [root@centos7-web ~]# ls -hltr /var/www/html/redhat-release.html lrwxrwxrwx 1 root root 19 Sep 21 16:15 /var/www/html/redhat-release.html -> /etc/redhat-release [root@centos7-web ~]# curl http://localhost/redhat-release.html CentOS Linux release 7.2.1511 (Core) [root@centos7-web ~]# vim /etc/httpd/conf/httpd.conf Options None ##改成Options None [root@centos7-web ~]# systemctl reload httpd [root@centos7-web ~]# curl http://localhost/redhat-release.html <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <html><head> <title>403 Forbidden</title> </head><body> ##Author : Leshami <h1>Forbidden</h1> ## Blog : http://blog.csdn.net/leshami <p>You don't have permission to access /redhat-release.html on this server.</p> </body></html>
相关文章推荐
- 配置Apache中的httpd ,让一个普通目录支持perl,不支持php
- wamp3.06版本的80端口的配置 1 找到 C:\wamp64\bin\apache\apache2.4.23\conf\extra 目录 打开 httpd-vhosts.conf 文件复制下
- ftp用户权限(其实是PHP的php.ini或APACHE的httpd.conf配置 限制目录访问)
- linux下的apache在httpd.conf配置目录别名和include引入自配置文件配置的方法
- apache httpd 禁止目录浏览 及 安全配置
- 让apache显示目录列表的配置方法
- apache 2.4.1 配置网页目录与文件列表目录
- 虚拟主机中让apache显示目录列表的配置方法
- Apache2.4(httpd)配置多个虚拟目录,分别设置代理访问Node.js
- 改apache的默认目录配置文件httpd.conf,apache 403错误的解决办法
- apache config httpd.conf file防止目录列表被浏览、敏感目录或文件限制IP访问
- 改apache的默认目录配置文件httpd.conf,apache 403错误的解决办法 【转】
- 配置Apache的某个特定目录使其禁用php解析
- Apache(httpd)配置Directory目录,Order,deny,allow说明
- php-7.1和apache httpd-2.4.29 windows环境配置
- 您不具备查看该目录或页面的权限,因为访问控制列表 (ACL) 对Web服务器上的该资源进行了配置
- SVNListParentPath on配置以及在根目录显示项目列表
- Apache httpd.conf 配置文件语法验证
- 配置的好的Apache和PHP语言的环境下,如何在Apache目录下htdocs/html目录下 同时部署两个项目呢
- 利用httpd配置虚拟目录创建下载站点