Apache安全之404页面和默认页面安全
404页面敏感信息的隐藏
首先开启httpd服务,然后curl -I 本机IP
查看一下响应头信息
可以在这里清楚地看到apache的版本号,和操作系统
在这里我们要将这些敏感信息隐藏
首先打开/etc/httpd/conf/httpd.conf
ServerTokens OS 改为 ServerTokens Prod
ServerSignature On 改为 ServerSignature Off
保存退出
接着打开/etc/php.ini
将expose_php On 改为 expose_php Off
保存退出重启服务
二、重新定义404界面,给用户更好的交互体验
加固方法(1)
1.先准备好一个自定义的404界面
2.vim /etc/httpd/conf/httpd.conf
将注释去掉,再将404后面的index.html改为404.htlm
ErrorDocument 404 /404.html
将404文件放到网站根目录/etc/www/html
加固方法(2)
1.编辑httpd.conf
在<Directory "/var/www/html"> 下面将
Options FollowSymlinks
AllowOverride None
</Directory>
改为
<Directory "/var/www/html">
Options FollowSymlinks
AllowOverride All
</Directory>
再将下面的行去掉注释
LoadModule rewrite_module /modules/mod_rewrite.so
保存退出
在根目录下创建文件.htaccess
在里面输入ErrorDocument 404/404.html
保存退出
三、删除默认页面
1.在httpd.conf文件下
将 Directorylndex index.html index.html.var
修改为Directorylndex index.php index.html index.htm
保存退出
在网站根目录
/var/www/html
创建一个自己准备好的index.php文件
重启服务