services/{fail2ban,postgres}: Split up from athame

This commit is contained in:
kat witch 2021-04-27 22:29:16 +01:00
parent 8a4e5992bb
commit 9b1602ec36
No known key found for this signature in database
GPG key ID: 1B477797DCA5EC72
2 changed files with 42 additions and 0 deletions

37
services/fail2ban.nix Normal file
View file

@ -0,0 +1,37 @@
{ config, pkgs, ... }:
{
services.fail2ban = {
enable = true;
jails = {
DEFAULT = ''
bantime = 1d
blocktype = DROP
logpath = /var/log/auth.log
'';
ssh = ''
enabled = true
filter = sshd
maxretry = 4
action = iptables[name=SSH, port=ssh, protocol=tcp]
'';
sshd-ddos = ''
enabled = true
filter = sshd-ddos
maxretry = 4
action = iptables[name=ssh, port=ssh, protocol=tcp]
'';
};
};
environment.etc."fail2ban/filter.d/sshd-ddos.conf" = {
enable = true;
text = ''
[Definition]
failregex = sshd(?:\[\d+\])?: Did not receive identification string from <HOST>$
ignoreregex =
'';
};
systemd.services.fail2ban.serviceConfig.LimitSTACK = 128 * 1024;
}

5
services/postgres.nix Normal file
View file

@ -0,0 +1,5 @@
{ config, pkgs, ... }:
{
services.postgresql.enable = true;
}