mirror of
https://github.com/Superredstone/nixos.git
synced 2026-08-19 11:48:57 +02:00
35 lines
836 B
Nix
35 lines
836 B
Nix
{ lib, ... }:
|
|
{
|
|
services.fail2ban = {
|
|
enable = true;
|
|
ignoreIP = [ "192.168.1.0/24" ];
|
|
bantime = "4h";
|
|
bantime-increment = {
|
|
enable = true;
|
|
multipliers = "1 2 4 8 16 32 64";
|
|
overalljails = true;
|
|
};
|
|
jails = {
|
|
caddy-filter.settings = {
|
|
enabled = true;
|
|
port = "http,https";
|
|
action = "iptables-multiport";
|
|
filter = "caddy-filter";
|
|
logpath = "/var/log/caddy/*.log";
|
|
maxretry = 8;
|
|
backend = "auto";
|
|
};
|
|
};
|
|
};
|
|
|
|
environment.etc = {
|
|
"fail2ban/filter.d/caddy-filter.local".text = lib.mkDefault (
|
|
lib.mkAfter ''
|
|
[Definition]
|
|
failregex = ^\{"level":"info","ts":\d+\.\d+,"logger":"http\.log\.access\.log\d*","msg":"handled request".*"remote_ip":"<HOST>".*"status":4\d{2}.*
|
|
ignoreregex =
|
|
''
|
|
);
|
|
};
|
|
}
|