收到安全掃描報告顯示 Apache 存在漏洞?本文梳理企業級 Apache 加固的常見項目、配置修改要點、驗證方法,助你快速完成合規整改。
Require all denied 限制敏感路徑訪問。Server: Apache/2.4.41 (Unix) 暴露版本、OS 信息。httpd.conf 設置:
ServerTokens Prod
ServerSignature Off
僅返回 Server: Apache,關閉錯誤頁面版本尾巴。
Options Indexes 或顯式設置 Options -Indexes。manual/、icons/、cgi-bin/ 等默認內容,擴大攻擊面。httpd.conf 中 Include conf/extra/httpd-manual.conf 等,物理刪除無用目錄。<Directory /var/www/html>
<LimitExcept GET POST HEAD>
Require all denied
</LimitExcept>
</Directory>
ssl.conf 強制現代配置:
SSLProtocol -all +TLSv1.2 +TLSv1.3
SSLCipherSuite HIGH:!aNULL:!MD5:!3DES:!RC4
SSLHonorCipherOrder on
# 啟用 HSTS
Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains"
mod_headers 模塊並配置:
Header always set X-Content-Type-Options nosniff
Header always set X-Frame-Options DENY
Header always set Content-Security-Policy "default-src 'self'; script-src 'self'"
Header always set Referrer-Policy strict-origin-when-cross-origin
FollowSymLinks (改用 SymLinksIfOwnerMatch) 防止符號鏈接跳轉。Require all denied 或 IP 白名單。apachectl -t / httpd -t。apachectl graceful。安全加固不是一次性動作,而是持續的基線管理與應急響應能力建設。