Apache安全加固规范
文章目錄
- 1.使用情況
- 2.技能要求
- 3.前置條件
- 4.詳細操作
- 4.1 禁止目錄瀏覽
- 4.2 日志配置
- 4.3 限制目錄執行權限
- 4.4 錯誤頁面處理
- 4.5 最佳操作實踐
- 4.6 風險操作項
1.使用情況
適用于使用Apahce進行部署的Web網站。
2.技能要求
熟悉Apache配置文件,能夠利用Apache進行建站,并能針對站點使用Apache進行安全加固。
3.前置條件
1、根據站點開放端口,進程ID,確認站點采用Apache進行部署;
2、找到Apache配置文件
4.詳細操作
4.1 禁止目錄瀏覽
<1>備份httpd.conf配置文件,修改內容:
Options FollowSymLinks
AllowOverride None #在151行下添加
Order allow,deny
Allow from all
將Options Indexes FollowSymLinks 中的Indexes 去掉,就可以禁止 Apache顯示該目錄結構。
(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
增加紅色字體這一行,即可開啟apache日志并且按照日期劃分創建。
(2) 重新啟動 Apache 服務
4.3 限制目錄執行權限
(1)備份httpd.conf配圖文件,修改內容:151后加
Order Allow,Deny
Deny from all
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
其中Customxxox.html 為要設置的錯誤頁面。
(2)重新啟動 Apache 服務生效
4.5 最佳操作實踐
4.5.1隱藏Apache版本號
(1)備份httpd.conf文件,修改內容:最后加
ServerSignature Off
ServerTokens Prod
(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
只允許從192.168.204.0/24 IP段內的用戶訪問,一般在限制后臺訪問時用到。
4.6 風險操作項
4.6.1 Apache 降權
Linux中操作步驟為:
備份httpd.conf文件
修改:
User nobody
Group# -1
重啟 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生效
上傳文件的大小也會受到此參數限制。
總結
以上是生活随笔為你收集整理的Apache安全加固规范的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Nginx 安全加固规范
- 下一篇: 【中间件安全】Tomcat 安全加固规范