Apache安全加固规范

【中间件安全】Apache安全加固规范

1.使用状况

适用于使用Apahce进行部署的Web网站。html

2.技能要求

熟悉Apache配置文件,可以利用Apache进行建站,并能针对站点使用Apache进行安全加固。web

3.前置条件

一、根据站点开放端口,进程ID,确认站点采用Apache进行部署;
二、找到Apache配置文件apache

4.详细操做

4.1 禁止目录浏览

<1>备份httpd.conf配置文件,修改内容:
Options FollowSymLinks
AllowOverride None #在151行下添加
Order allow,deny
Allow from all
将Options Indexes FollowSymLinks 中的Indexes 去掉,就能够禁止 Apache显示该目录结构。
图1
(2)设置 Apache 的默认页面:在/var/www/html下新建index.html,
DirectoryIndex index.html
其中index.html即为默认页面,可根据状况改成其它文件,部分服务器须要在目录下新建空白的index.htm才能
生效。
(3)从新启动 Apache 服务安全

4.2 日志配置

(1)备份httpd.conf配置文件,修改内容:
Window下:
LogFormat “%h%1%u%t1”%r1"%>s %b|"%i"1"%i,"" combined
CustomLog “|bin/rotatelogs.exe logs/localhost_access_log.%Y-%m-%d.log 86400~480” combined
图2
增长红色字体这一行,便可开启apache日志而且按照日期划分建立。
(2) 从新启动 Apache 服务服务器

4.3 限制目录执行权限

(1)备份httpd.conf配圖文件,修改内容:151后加
Order Allow,Deny
Deny from allide

4.4 错误页面处理

(1)备份httpd.conf配置文件,修改内容:
ErrorDocument 400/custom400.html
ErrorDocument 401/custom401.html
ErrorDocument 403 /custom403.html
ErrorDocument 404 /custom404.html
ErrorDocument 405/custom405.html
ErrorDocument 500/custom500.html
图3
其中Customxxox.html 为要设置的错误页面。
(2)从新启动 Apache 服务生效svg

4.5 最佳操做实践

4.5.1隐藏Apache版本号
(1)备份httpd.conf文件,修改内容:最后加
ServerSignature Off
ServerTokens Prod
图4
(2) 从新启动 Apache 服务字体

4.5.2限制IP访问
(1)备份httpd.conf配置文件,修改内容:151行后加
Options FollowSymLinks
AllowOverride None
Order Deny,Allow
Deny from all
Allow from 192.168.204.0/24
图5
只容许从192.168.204.0/24 IP段内的用户访问,通常在限制后台访问时用到。网站

4.6 风险操做项

4.6.1 Apache 降权
Linux中操做步骤为:
备份httpd.conf文件
修改:
User nobody
Group# -1
图6
重启 APACHE
./apachectl restartTOMCAT操做系统安全配置系统加固指南
Windows中操做步骤为:
新建系统用户组www,新建系统用户apache并设置密码。
运行services.msc打开服务管理界面,双击apache2.2服务打开属性页,点击“登陆”选项卡,选择“此帐户”,填写帐号和密码,肯定。操作系统

4.6.2 防CC攻击
备份httpd.conf配置文件,修改内容:
Timeout 10
KeepAlive On
KeepAliveTimeout 15
AcceptFilter http data
AcceptFilter https data
从新启动 Apache 服务生效

4.6.3 限制请求消息长度 备份httpd.conf配置文件,修改内容: LimitRequestBody 102400 重启apache生效 上传文件的大小也会受到此参数限制。