Apache安全加固规范
文章目錄
- 1.使用情況
- 2.技能要求
- 3.前置條件
- 4.詳細(xì)操作
- 4.1 禁止目錄瀏覽
- 4.2 日志配置
- 4.3 限制目錄執(zhí)行權(quán)限
- 4.4 錯(cuò)誤頁面處理
- 4.5 最佳操作實(shí)踐
- 4.6 風(fēng)險(xiǎn)操作項(xiàng)
1.使用情況
適用于使用Apahce進(jìn)行部署的Web網(wǎng)站。
2.技能要求
熟悉Apache配置文件,能夠利用Apache進(jìn)行建站,并能針對站點(diǎn)使用Apache進(jìn)行安全加固。
3.前置條件
1、根據(jù)站點(diǎn)開放端口,進(jìn)程ID,確認(rèn)站點(diǎn)采用Apache進(jìn)行部署;
2、找到Apache配置文件
4.詳細(xì)操作
4.1 禁止目錄瀏覽
<1>備份httpd.conf配置文件,修改內(nèi)容:
Options FollowSymLinks
AllowOverride None #在151行下添加
Order allow,deny
Allow from all
將Options Indexes FollowSymLinks 中的Indexes 去掉,就可以禁止 Apache顯示該目錄結(jié)構(gòu)。
(2)設(shè)置 Apache 的默認(rèn)頁面:在/var/www/html下新建index.html,
DirectoryIndex index.html
其中index.html即為默認(rèn)頁面,可根據(jù)情況改為其它文件,部分服務(wù)器需要在目錄下新建空白的index.htm才能
生效。
(3)重新啟動(dòng) Apache 服務(wù)
4.2 日志配置
(1)備份httpd.conf配置文件,修改內(nèi)容:
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
增加紅色字體這一行,即可開啟apache日志并且按照日期劃分創(chuàng)建。
(2) 重新啟動(dòng) Apache 服務(wù)
4.3 限制目錄執(zhí)行權(quán)限
(1)備份httpd.conf配圖文件,修改內(nèi)容:151后加
Order Allow,Deny
Deny from all
4.4 錯(cuò)誤頁面處理
(1)備份httpd.conf配置文件,修改內(nèi)容:
ErrorDocument 400/custom400.html
ErrorDocument 401/custom401.html
ErrorDocument 403 /custom403.html
ErrorDocument 404 /custom404.html
ErrorDocument 405/custom405.html
ErrorDocument 500/custom500.html
其中Customxxox.html 為要設(shè)置的錯(cuò)誤頁面。
(2)重新啟動(dòng) Apache 服務(wù)生效
4.5 最佳操作實(shí)踐
4.5.1隱藏Apache版本號
(1)備份httpd.conf文件,修改內(nèi)容:最后加
ServerSignature Off
ServerTokens Prod
(2) 重新啟動(dòng) Apache 服務(wù)
4.5.2限制IP訪問
(1)備份httpd.conf配置文件,修改內(nèi)容:151行后加
Options FollowSymLinks
AllowOverride None
Order Deny,Allow
Deny from all
Allow from 192.168.204.0/24
只允許從192.168.204.0/24 IP段內(nèi)的用戶訪問,一般在限制后臺訪問時(shí)用到。
4.6 風(fēng)險(xiǎn)操作項(xiàng)
4.6.1 Apache 降權(quán)
Linux中操作步驟為:
備份httpd.conf文件
修改:
User nobody
Group# -1
重啟 APACHE
./apachectl restartTOMCAT操作系統(tǒng)安全配置系統(tǒng)加固指南
Windows中操作步驟為:
新建系統(tǒng)用戶組www,新建系統(tǒng)用戶apache并設(shè)置密碼。
運(yùn)行services.msc打開服務(wù)管理界面,雙擊apache2.2服務(wù)打開屬性頁,點(diǎn)擊“登錄”選項(xiàng)卡,選擇“此賬戶”,填寫賬號和密碼,確定。
4.6.2 防CC攻擊
備份httpd.conf配置文件,修改內(nèi)容:
Timeout 10
KeepAlive On
KeepAliveTimeout 15
AcceptFilter http data
AcceptFilter https data
重新啟動(dòng) Apache 服務(wù)生效
4.6.3 限制請求消息長度
備份httpd.conf配置文件,修改內(nèi)容:
LimitRequestBody 102400
重啟apache生效
上傳文件的大小也會受到此參數(shù)限制。
總結(jié)
以上是生活随笔為你收集整理的Apache安全加固规范的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Nginx 安全加固规范
- 下一篇: 【中间件安全】Tomcat 安全加固规范