Products
96SEO 2025-07-29 04:24 10
在配置Web应用防火墙之前,我们需要确保服务器周围已经准备优良。
yum update -y
yum install -y httpd
systemctl start httpd
systemctl enable httpd
ModSecurity是一个开源的Web应用防火墙引擎,我们能从官方GitHub仓库下载最新鲜版本的源代码。
git clone https://github.com/SpiderLabs/ModSecurity.git
cd ModSecurity
./configure
make
make install
cp ./apache2/mod_security2.so /usr/lib64/httpd/modules/
Include conf/mod_security2.conf
配置ModSecurity以启用规则引擎并指定审计日志路径。
mkdir /var/log/mod_security
chown apache:apache /var/log/mod_security
LoadModule security2_module modules/mod_security2.so
SecRuleEngine On
SecAuditEngine RelevantOnly
SecAuditLog /var/log/mod_security/SecAuditLogType Serial
systemctl restart httpd
OWASP Core Rule Set是一组由OWASP社区维护的ModSecurity规则集,它包含了一巨大堆的平安规则。
git clone https://github.com/SpiderLabs/owasp-modsecurity-crs.git /etc/httpd/crs
cp /etc/httpd/crs/crs- /etc/httpd/crs/crs-
Include /etc/httpd/crs/crs-Include /etc/httpd/crs/rules/*.conf
为了测试ModSecurity是不是正常干活,我们能尝试发起一个包含SQL注入打的求。
curl "http://your-server-ip/?id=1' OR '1'='1"
在实际用过程中,我们兴许会遇到一些误报的情况,即ModSecurity将正常的求误判为打求。
systemctl restart httpd
mkdir /var/log/mod_security
chown apache:apache /var/log/mod_security
Include conf/mod_security.conf
为了确保ModSecurity的正常运行,我们需要对其进行监控和维护。
、优化和维护ModSecurity。希望这玩意儿配置案例能够帮你更优良地护着Web应用的平安。
Demand feedback