## 服务器 # 测试前 $ sudo fail2ban-client status nginx-limit-req Status for the jail: nginx-limit-req |- Filter | |- Currently failed: 0 | |- Total failed: 0 | `- File list: /var/log/nginx/error.log `- Actions |- Currently banned: 0 |- Total banned: 0 `- Banned IP list:
# 测试后 $ sudo fail2ban-client status nginx-limit-req Status for the jail: nginx-limit-req |- Filter | |- Currently failed: 1 | |- Total failed: 8 | `- File list: /var/log/nginx/error.log `- Actions |- Currently banned: 1 |- Total banned: 1 `- Banned IP list: 1.2.3.4
$ tail /var/log/nginx/error.log 2019/09/27 18:04:55 [notice] 8836#8836: signal process started 2019/09/27 18:22:10 [notice] 11834#11834: signal process started 2019/09/27 18:22:18 [error] 11835#11835: *1126 limiting requests, excess: 5.911 by zone "perip", client: 218.4.167.126, server: target-host, request: "GET / HTTP/1.1", host: "target-host" 2019/09/27 18:22:18 [error] 11835#11835: *1127 limiting requests, excess: 5.891 by zone "perip", client: 218.4.167.126, server: target-host, request: "GET / HTTP/1.1", host: "target-host" 2019/09/27 18:22:18 [error] 11835#11835: *1128 limiting requests, excess: 5.879 by zone "perip", client: 218.4.167.126, server: target-host, request: "GET / HTTP/1.1", host: "target-host" 2019/09/27 18:22:18 [error] 11835#11835: *1129 limiting requests, excess: 5.864 by zone "perip", client: 218.4.167.126, server: target-host, request: "GET / HTTP/1.1", host: "target-host" 2019/09/27 18:22:19 [error] 11835#11835: *1130 limiting requests, excess: 5.849 by zone "perip", client: 218.4.167.126, server: target-host, request: "GET / HTTP/1.1", host: "target-host"
# 取消ban # sudo fail2ban-client set nginx-http-auth unbanip 111.111.111.111 # 没有测试,默认bantime是10m,等它自动解封 $ date Fri Sep 27 18:34:36 CST 2019 $ sudo fail2ban-client status nginx-limit-req Status for the jail: nginx-limit-req |- Filter | |- Currently failed: 1 | |- Total failed: 8 | `- File list: /var/log/nginx/error.log `- Actions |- Currently banned: 0 |- Total banned: 1 `- Banned IP list: