网站可能被同行朋友来抓站,或者ddos攻击所以必须做出相应的策略

 

1. 使用 fail2ban

fail2ban是通过扫描log来异步判断是否用iptable封禁的,所以对原系统影响比较小,而且不需要重新配置nginx。不过不知道访问量太大是否撑得住。

首先在/etc/fail2ban/jail.conf里加入

[http-get-dos]
enabled = true
port = http,https
filter = nginx-bansniffer
logpath = /usr/local/nginx/logs/segmentfault.log
maxretry = 120
findtime = 120
bantime = 3600
action = iptables[name=HTTP, port=http, protocol=tcp]

然后新建/etc/fail2ban/filter.d/nginx-bansniffer.conf,原来一个nginx的配置文件和这个类似

[Definition]

failregex = <HOST> -.*- .*HTTP/1.* .* .*$
ignoreregex =

最后重启fail2ban服务即可,在上面的配置中,我们对每120秒有超过120次访问的ip,封禁1小时。

 

 

2. ngx-lu-waf脚本  https://github.com/loveshell/ngx_lua_waf

nginx需要重新安装使之支持ngx-lua模块

部署地址 http://www.ttlsa.com/nginx/nginx-modules-ngx_lua/

            http://blog.slogra.com/post-497.html

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-01-24
  • 2021-09-02
  • 2021-12-09
猜你喜欢
  • 2021-07-08
  • 2022-12-23
  • 2022-12-23
  • 2021-11-04
  • 2021-11-16
  • 2021-10-12
相关资源
相似解决方案