攻擊者透過多種手段耗盡 Apache 系統資源(CPU、記憶體、頻寬、磁碟 I/O),導致服務緩慢或癱瘓。Apache 普及度高,長期處於攻擊首線,主要威脅向量:
httpd-announce 郵件列表、CVE 資料庫、廠商安全公告。# 僅載入必要模組,註釋其餘
LoadModule authz_core_module modules/mod_authz_core.so
LoadModule authz_host_module modules/mod_authz_host.so
LoadModule dir_module modules/mod_dir.so
LoadModule log_config_module modules/mod_log_config.so
LoadModule mime_module modules/mod_mime.so
# 禁用:mod_autoindex, mod_cgi, mod_userdir, mod_info, mod_status 等
# httpd.conf
User apache
Group apache
# 確保 /var/www、/var/log/httpd 擁有者為 apache:apache
Options -Indexes
DirectoryIndex index.php index.html
# 移除預設 welcome page、icons 別名、manual 別名
ServerTokens Prod
ServerSignature Off
LimitRequestBody 10485760 # 10MB
LimitRequestFields 100
LimitRequestFieldSize 8190
LimitRequestLine 8190
MaxClients 150
MaxRequestsPerChild 1000
yum install mod_security mod_security_crs
# 載入 OWASP CRS 規則集,啟用 SQLi、XSS、RCE 基礎防護
SSLProtocol all -SSLv2 -SSLv3 -TLSv1 -TLSv1.1
SSLCipherSuite HIGH:!aNULL:!MD5:!3DES
SSLHonorCipherOrder on
Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains"
LogFormat 記錄 %{X-Forwarded-For}i、%D(請求處理微秒)、%>s(狀態碼)。安全是持續過程而非一次性配置。遵循「最小權限、縮小攻擊面、深度防禦、持續監控」原則,配合自動化補丁管理與日誌分析,才能將 Apache 風險控制在可接受範圍內。