CentOS 8 Apache 使用 ModSecurity 防止 DDOS

问题:

1,CentOS 7 中的源中默认有 mod_evasive,而 CentOS 8 中没找到 mod_evasive。

2,Apache 官方文档中,关于 Denial of Service (DoS) attacks 没有类似 mod_evasive 的功能。官方建议限制 IP 连接数相关的方法,最好使用操作系统上的防火墙。

http://httpd.apache.org/docs/current/misc/security_tips.html

3,Apache 2.4以上版本,新增了mod_ratelimit,针对请求限流,不能针对IP。也不能屏蔽 IP

http://httpd.apache.org/docs/current/mod/mod_ratelimit.html

4, Nginx 的这个模块真好 ngx_http_limit_req_module,可以考虑 Web 最外层用 Nginx 做代理。

https://nginx.org/en/docs/http/ngx_http_limit_req_module.html


方案:使用 mod_security 的防 DDOS 规则

一定要在引入的规则之前添加如下设置:

SecAction "id:'900011',phase:1,t:none,setvar:'tx.dos_burst_time_slice=10',setvar:'tx.dos_counter_threshold=6',setvar:'tx.dos_block_timeout=30',nolog,pass"


意思是在10秒内如果超过 6 次请求,则屏蔽 30秒。测试有效,但发现该规则不是基于 IP 的,好像是基于请求的。先放在这里等以后再研究。

for I in {1..60}; do curl https://test.com/; sleep 0.5; done

ab -c 60 -n 999999 https://test.com/






参考:

https://www.cnblogs.com/wuweidong/category/1177159.html

https://blog.csdn.net/weixin_30466421/article/details/96364832

声明:本站所有文章和图片,如无特殊说明,均为原创发布。商业转载请联系作者获得授权,非商业转载请注明出处。
真诚赞赏,手留余香
赞赏
随机推荐
WP_REST_Response 返回结果类
MySQL 字符串截取函数 SUBSTRING_INDEX
WordPress 用户信息
二分查找法
WordPress 的用户角色和权限
Node.js 控制台进度条实现原理
MySQL 批量插入数据时如何解决重复问题
阿里云内容安全 API 签名机制