diff --git a/CADDY.md b/CADDY.md index 8dd369d..0ed1e11 100644 --- a/CADDY.md +++ b/CADDY.md @@ -38,27 +38,9 @@ sudo systemctl restart caddy ### Fail2ban Service that reads logs from various sources, finds password trials and bans ip if it tries to brute force password. -Write to `/etc/fail2ban/filter.d/caddy-auth.conf` -```conf -[Definition] -failregex = 401 REDACTED$ -ignoreregex = -``` +Copy [delpoy/caddy-auth.conf](./delpoy/caddy-auth.conf) to `/etc/fail2ban/filter.d/caddy-auth.conf` +Copy [delpoy/caddy-auth.local](./delpoy/caddy-auth.local) to `/etc/fail2ban/jail.d/caddy-auth.local` -Write to `/etc/fail2ban/jail.d/caddy-auth.local` -```conf -[caddy-auth] -enabled = true -filter = caddy-auth # /etc/fail2ban/filter.d/caddy-auth.conf -logpath = /var/log/caddy/files-auth.log -backend = auto # without it on debian fail2ban will use systemd logging and to read caddy log -maxretry = 10 # N wrong passwords -findtime = 10m # sent during 10 minutes -bantime = 1h # ban for 1 hour -banaction = iptables-allports # ban the ip for all ports -protocol = all # and all protocols -ignoreip = 127.0.0.1/8 ::1 # ignore localhost -``` Reload fail2ban: ```sh sudo fail2ban-client reload diff --git a/deploy/caddy-auth.conf b/deploy/caddy-auth.conf new file mode 100644 index 0000000..8d890ac --- /dev/null +++ b/deploy/caddy-auth.conf @@ -0,0 +1,3 @@ +[Definition] +failregex = 401 REDACTED$ +ignoreregex = \ No newline at end of file diff --git a/deploy/caddy-auth.local b/deploy/caddy-auth.local new file mode 100644 index 0000000..7105f35 --- /dev/null +++ b/deploy/caddy-auth.local @@ -0,0 +1,11 @@ +[caddy-auth] +enabled = true +filter = caddy-auth # /etc/fail2ban/filter.d/caddy-auth.conf +logpath = /var/log/caddy/files-auth.log +backend = auto # without it on debian fail2ban will use systemd logging and to read caddy log +maxretry = 10 # N wrong passwords +findtime = 10m # sent during 10 minutes +bantime = 1h # ban for 1 hour +banaction = iptables-allports # ban the ip for all ports +protocol = all # and all protocols +ignoreip = 127.0.0.1/8 ::1 # ignore localhost \ No newline at end of file diff --git a/deploy/serveg.service b/deploy/serveg.service new file mode 100644 index 0000000..4c71803 --- /dev/null +++ b/deploy/serveg.service @@ -0,0 +1,19 @@ +[Unit] +Description=serveg file server +After=network-online.target +Wants=network-online.target + +[Service] +Type=simple +User=filebin +Group=filebin +WorkingDirectory=/home/filebin +ExecStart=/home/filebin/serveg +Restart=on-failure +RestartSec=5 + +KillSignal=SIGTERM +TimeoutStopSec=10 + +[Install] +WantedBy=multi-user.target