以下是利用Apache2提高安全性的关键措施:
/etc/apache2/apache2.conf
),设置ServerTokens Prod
和ServerSignature Off
,隐藏版本及系统信息。a2dismod
命令禁用非必要模块(如mod_php
、mod_autoindex
),减少攻击面。mod_ssl
模块,配置HTTPS证书(可使用Let’s Encrypt免费证书),强制跳转HTTP到HTTPS。<Directory>
指令限制目录访问权限,禁止敏感文件(如.htaccess
)被访问。.htpasswd
设置目录认证,或通过IP白名单限制访问。mod_security
模块,配置防XSS、SQL注入等规则。X-XSS-Protection
、Content-Security-Policy
)。参考来源: