目錄
- 賬號口令和認證授權
- 日誌配置
- 禁止apache列表顯示文件
- 設置拒絕服務防範
- 刪除安裝的無用文件
- 檢查apache服務器默認端口
- 禁止apache訪問web目錄之外的任何文件
- 設置apache錯誤頁面重定向
- 限制HTTP請求的消息主體的大小
賬號口令和認證授權
檢查是否隱藏apache的版本號及其他敏感信息
檢查內容
隱藏Apache的版本號及其它敏感信息
檢查操作步驟
編輯配置文件httpd.conf
判定條件
ServerSignature Off
ServerTokens Prod
加固方案操作建議
參考配置操作
修改httpd.conf配置文件:
ServerSignature Off
ServerTokens Prod
加固方案補充說明
存在ServerTokens值爲Prod,ServerSignature值爲Off
檢查是否專門的用戶帳號和組運行Apache
檢查內容
以專門的用戶帳號和組運行Apache
檢查操作步驟
根據需要爲Apache創建用戶、組
修改httpd.conf配置文件,添加如下語句:
User apache
Group apachegroup
其中apache、apachegroup分別是爲Apache創建的用戶和組。
判定條件
User apache
Group apachegroup
基準值
Group,User
加固方案操作建議
修改httpd.conf配置文件,添加如下語句:
User apache
Group apachegroup
其中apache、apachegroup分別是爲Apache創建的用戶和組。
加固方案補充說明
1、根據不同用戶,取不同的名稱。
2、爲用戶設置適當的家目錄和shell。
存在Group和user組
日誌配置
檢查是否配備apache日誌功能
檢查項內容
設備應配置日誌功能,對運行錯誤、用戶訪問等進行記錄,記錄內容包括時間,用戶使用的IP地址等內容
檢查操作步驟
查看配置文件httpd.conf
編輯httpd.conf配置文件,設置日誌記錄文件、記錄內容、記錄格式。
LogLevel notice
ErrorLog logs/error_log
LogFormat “%h %l %u %t “%r” %>s %b “%{Accept}i” “%{Referer}i” “%{User-Agent}i”” combined
CustomLog logs/access_log combined
判定條件
查看logs目錄中相關日誌文件內容,記錄完整。
基準值
CustomLog,LogFormat,ErrorLog,LogLevel
加固方案操作建議
編輯httpd.conf配置文件,設置日誌記錄文件、記錄內容、記錄格式。
LogLevel notice
ErrorLog logs/error_log
LogFormat “%h %l %u %t “%r” %>s %b “%{Accept}i” “%{Referer}i” “%{User-Agent}i”” combined
CustomLog logs/access_log combined
ErrorLog指令設置錯誤日誌文件名和位置。錯誤日誌是最重要的日誌文件,Apache httpd將在這個文件中存放診斷信息和處理請求中出現的錯誤。若要將錯誤日誌送到Syslog,則設置:ErrorLog syslog。
CustomLog指令設置訪問日誌的文件名和位置。訪問日誌中會記錄服務器所處理的所有請求。
LogFormat設置日誌格式。LogLevel用於調整記錄在錯誤日誌中的信息的詳細程度,建議設置爲notice。
加固方案補充說明
用戶日誌CustomLog,日誌格式LogFormat,錯誤日誌ErrorLog,日誌等級LogLevel這四個字段後面有配置的日誌信息
檢查是否禁止Apache列表顯示文件
檢查項內容
禁止Apache列表顯示文件
檢查操作步驟
編輯httpd.conf配置文件,將Options Indexes FollowSymLinks中的Indexes 去掉,就可以禁止 Apache 顯示該目錄結構。Indexes 的作用就是當該目錄下沒有 index.html文件時,就顯示目錄結構
判定條件
當WEB目錄中沒有默認首頁如index.html文件時,不會列出目錄內容
基準值
Indexes
加固方案操作建議
編輯httpd.conf配置文件,
<Directory “/web”>
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
< /Directory >
將Options Indexes FollowSymLinks中的Indexes 去掉,就可以禁止 Apache 顯示該目錄結構。Indexes 的作用就是當該目錄下沒有 index.html文件時,就顯示目錄結構。
其中index.html即爲默認頁面,可根據情況改爲其它文件。
加固方案補充說明
存在Options Indexes FollowSymLinks
檢查是否設置拒絕服務防範
檢查項內容
拒絕服務防範
檢查操作步驟
編輯配置文件httpd.conf
判定條件
Timeout 10 KeepAlive On
KeepAliveTimeout 15
AcceptFilter http data
AcceptFilter https data
基準值
AcceptFilter https data,AcceptFilter http data,KeepAliveTimeout 15,Timeout 10 KeepAlive On
加固方案操作建議
編輯httpd.conf配置文件,
Timeout 10 KeepAlive On
KeepAliveTimeout 15
AcceptFilter http data
AcceptFilter https data
(2)重新啓動Apache服務
加固方案補充說明
同時存在AcceptFilter https data,AcceptFilter http data,KeepAliveTimeout 15,Timeout 10 KeepAlive On
是否刪除安裝的無用文件
檢查項內容
刪除缺省安裝的無用文件
檢查操作步驟
刪除缺省安裝的無用文件#rm %Apache_Home%/htdocs/* #rm %Apache_Home%/cgi-bin/#rm %Apache_Home%/manual#rm %Apache_Home%/httpd-2.2.4
判定條件
刪除缺省安裝的無用文件#rm %Apache_Home%/htdocs/* #rm %Apache_Home%/cgi-bin/#rm %Apache_Home%/manual#rm %Apache_Home%/httpd-2.2.4
加固方案操作建議
刪除缺省HTML文件:
#rm -rf /usr/local/apache2/htdocs/*
刪除缺省的CGI腳本:
#rm –rf /usr/local/apache2/cgi-bin/*
刪除Apache說明文件:
#rm –rf /usr/local/apache2/manual
刪除源代碼文件:
#rm -rf /path/to/httpd-2.2.4*
根據安裝步驟不同和版本不同,某些目錄或文件可能不存在或位置不同。
加固方案補充說明
htdocs,cgi-bin,manual的文件數都等於0
檢查Apache服務器默認端口
檢查項內容
更改Apache服務器默認端口
檢查操作步驟
修改httpd.conf配置文件,更改默認端口到8080
判定條件
Listen x.x.x.x:8080
基準值
8080
加固方案操作建議
(1)修改httpd.conf配置文件,更改默認端口到8080
Listen x.x.x.x:8080
(2)重啓Apache服務
加固方案補充說明
存在Listen x.x.x.x:8080
檢查是否禁止Apache訪問Web目錄之外的任何文件
檢查項內容
禁止Apache訪問Web目錄之外的任何文件
檢查操作步驟
查看httpd.conf配置文件
編輯httpd.conf配置文件,
<Directory / >
Order Deny,Allow
Deny from all
< /Directory>
判定條件
編輯httpd.conf配置文件,
<Directory / >
Order Deny,Allow
Deny from all
< /Directory>
基準值
Order Deny,Deny from all
加固方案操作建議
編輯httpd.conf配置文件,
<Directory / >
Order Deny,Allow
Deny from all
< /Directory>
加固方案補充說明
設置可訪問目錄,
<Directory /web>
Order Allow,Deny
Allow from all
< /Directory>
其中/web爲網站根目錄。
根目錄下面,存在Deny from all和Order Deny
檢查是否設置Apache錯誤頁面重定向
檢查項內容
Apache錯誤頁面重定向
檢查操作步驟
查看配置文件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爲要設置的錯誤頁面。
基準值
ErrorDocument
加固方案操作建議
(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服務
加固方案補充說明
存在ErrorDocument
限制http請求的消息主體的大小
檢查項內容
限制http請求的消息主體的大小
檢查操作步驟
查看配置文件httpd.conf
LimitRequestBody 102400
判定條件
LimitRequestBody 102400
加固方案操作建議
編輯httpd.conf配置文件,修改爲102400Byte
LimitRequestBody 102400
加固方案補充說明
LimitRequestBody小於等於 102400