setup fail2ban
This commit is contained in:
parent
7c8a6a0d09
commit
27a7b00565
1 changed files with 34 additions and 0 deletions
34
hosts/common/optional/fail2ban.nix
Normal file
34
hosts/common/optional/fail2ban.nix
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
{pkgs, ...}: {
|
||||||
|
|
||||||
|
environment.systemPackages = [pkgs.fail2ban];
|
||||||
|
|
||||||
|
environment.etc = {
|
||||||
|
"fail2ban/filter.d/nginx-bruteforce.conf".text = ''
|
||||||
|
[Definition]
|
||||||
|
failregex = ^<HOST>.*(GET|POST).* (404|444|403|400) .*$
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
services.fail2ban = {
|
||||||
|
enable = true;
|
||||||
|
maxretry = 5;
|
||||||
|
ignoreIP = [
|
||||||
|
];
|
||||||
|
bantime-increment = {
|
||||||
|
enable = true;
|
||||||
|
multipliers = "1 2 4 8 16 32 64";
|
||||||
|
maxtime = "168h";
|
||||||
|
};
|
||||||
|
jails = {
|
||||||
|
nginx-spam.settings = {
|
||||||
|
filter = "nginx-bruteforce";
|
||||||
|
action = "iptables-allports";
|
||||||
|
logpath = "/var/log/nginx/access.log";
|
||||||
|
backend = "auto";
|
||||||
|
findtime = 600;
|
||||||
|
bantime = 600;
|
||||||
|
maxretry = 10;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue