$ -weight: 500;">apt -weight: 500;">install ufw
-weight: 500;">apt -weight: 500;">install ufw
-weight: 500;">apt -weight: 500;">install ufw
ufw allow OpenSSH
ufw allow 80/tcp
ufw allow 443/tcp
ufw allow OpenSSH
ufw allow 80/tcp
ufw allow 443/tcp
ufw allow OpenSSH
ufw allow 80/tcp
ufw allow 443/tcp
ufw -weight: 500;">status numbered
ufw -weight: 500;">status numbered
ufw -weight: 500;">status numbered
ufw delete 3
ufw delete 3
ufw delete 3
ufw logging medium
ufw logging medium
ufw logging medium
-weight: 500;">apt -weight: 500;">install fail2ban
-weight: 500;">systemctl -weight: 500;">enable --now fail2ban
-weight: 500;">apt -weight: 500;">install fail2ban
-weight: 500;">systemctl -weight: 500;">enable --now fail2ban
-weight: 500;">apt -weight: 500;">install fail2ban
-weight: 500;">systemctl -weight: 500;">enable --now fail2ban
# /etc/fail2ban/filter.d/caddy-security.conf
[INCLUDES]
before = common.conf [Definition]
datepattern = "ts":<F-TIME>%%s</F-TIME>
failregex = ^.*"remote_ip":"<HOST>".*"-weight: 500;">status":(?:40[0-5]|429|5\d\d).*$
ignoreregex =
# /etc/fail2ban/filter.d/caddy-security.conf
[INCLUDES]
before = common.conf [Definition]
datepattern = "ts":<F-TIME>%%s</F-TIME>
failregex = ^.*"remote_ip":"<HOST>".*"-weight: 500;">status":(?:40[0-5]|429|5\d\d).*$
ignoreregex =
# /etc/fail2ban/filter.d/caddy-security.conf
[INCLUDES]
before = common.conf [Definition]
datepattern = "ts":<F-TIME>%%s</F-TIME>
failregex = ^.*"remote_ip":"<HOST>".*"-weight: 500;">status":(?:40[0-5]|429|5\d\d).*$
ignoreregex =
# /etc/fail2ban/jail.d/caddy.conf
[caddy-security]
enabled = true
port = http,https
filter = caddy-security
logpath = /home/deployer/*/log/access.log
backend = auto
maxretry = 20
findtime = 600
bantime = 3600
# /etc/fail2ban/jail.d/caddy.conf
[caddy-security]
enabled = true
port = http,https
filter = caddy-security
logpath = /home/deployer/*/log/access.log
backend = auto
maxretry = 20
findtime = 600
bantime = 3600
# /etc/fail2ban/jail.d/caddy.conf
[caddy-security]
enabled = true
port = http,https
filter = caddy-security
logpath = /home/deployer/*/log/access.log
backend = auto
maxretry = 20
findtime = 600
bantime = 3600
fail2ban-regex /home/deployer/myapp/log/access.log /etc/fail2ban/filter.d/caddy-security.conf
fail2ban-regex /home/deployer/myapp/log/access.log /etc/fail2ban/filter.d/caddy-security.conf
fail2ban-regex /home/deployer/myapp/log/access.log /etc/fail2ban/filter.d/caddy-security.conf
fail2ban-client reload
fail2ban-client reload
fail2ban-client reload
# /etc/fail2ban/jail.d/recidive.conf
[recidive]
enabled = true
logpath = /var/log/fail2ban.log
banaction = nftables[type=allports]
bantime = 604800
findtime = 86400
maxretry = 5
# /etc/fail2ban/jail.d/recidive.conf
[recidive]
enabled = true
logpath = /var/log/fail2ban.log
banaction = nftables[type=allports]
bantime = 604800
findtime = 86400
maxretry = 5
# /etc/fail2ban/jail.d/recidive.conf
[recidive]
enabled = true
logpath = /var/log/fail2ban.log
banaction = nftables[type=allports]
bantime = 604800
findtime = 86400
maxretry = 5
fail2ban-client -weight: 500;">status
fail2ban-client -weight: 500;">status
fail2ban-client -weight: 500;">status
fail2ban-client -weight: 500;">status caddy-security
fail2ban-client -weight: 500;">status caddy-security
fail2ban-client -weight: 500;">status caddy-security
grep "Ban\|Unban" /var/log/fail2ban.log | tail -20
grep "Ban\|Unban" /var/log/fail2ban.log | tail -20
grep "Ban\|Unban" /var/log/fail2ban.log | tail -20
nft list ruleset | grep fail2ban
nft list ruleset | grep fail2ban
nft list ruleset | grep fail2ban - Filter — a regex that extracts a client IP and timestamp from a log line
- Jail — combines a filter with thresholds: how many matches (maxretry) within what window (findtime) triggers a ban, and how long that ban lasts (bantime)
- Action — what happens when the threshold is crossed; typically an nftables or iptables rule that drops traffic from the offending IP