【中間件安全】Apache 安全加固規范


1. 適用情況

適用於使用Apahce進行部署的Web網站。

2. 技能要求

熟悉Apache配置文件,能夠利用Apache進行建站,並能針對站點使用Apache進行安全加固。

3. 前置條件

1、 根據站點開放端口,進程ID,確認站點采用Apache進行部署;

2、 找到Apache配置文件

4. 詳細操作

4.1 禁止目錄瀏覽

(1) 備份httpd.conf配置文件,修改內容:

Options FollowSymLinks

AllowOverride None

Order allow,deny

Allow from all

將Options Indexes FollowSymLinks 中的Indexes 去掉,就可以禁止 Apache顯示該目錄結構。

(2)設置 Apache 的默認頁面:

DirectoryIndex index.html

其中index.html即為默認頁面,可根據情況改為其它文件,部分服務器需要在目錄下新建空白的index.htm才能生效。

(3)重新啟動 Apache 服務

4.2 日志配置

(1) 備份httpd.conf配置文件,修改內容:

Window下:

LogFormat "%h %l %u %t \"%r\" %>s %b \"%i\" \"%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配置文件,修改內容:

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

其中Customxxx.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配置文件,修改內容:

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 restart

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生效

上傳文件的大小也會受到此參數限制。

 

最后

歡迎關注個人微信公眾號:Bypass--,每周原創一篇技術干貨。 

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM