cat <<'INI' | sudo tee /etc/fail2ban/jail.local >/dev/null
###############################################
# DEFAULT SETTINGS
###############################################
[DEFAULT]
bantime = 1h
findtime = 10m
maxretry = 5
backend = systemd
ignoreip = 127.0.0.1/8 ::1
action = %(action_)s
###############################################
# 1️⃣ SSH PROTECTION
###############################################
[sshd]
enabled = true
port = ssh
filter = sshd
logpath = /var/log/auth.log
maxretry = 5
###############################################
# 2️⃣ GENERAL NGINX PROTECTION (all VHOSTS)
###############################################
[nginx-general]
enabled = true
port = http,https
filter = nginx-http-auth
logpath = /var/log/nginx/error.log
maxretry = 5
findtime = 10m
bantime = 1h
###############################################################
# 3️⃣ APPLICATION LOGIN PROTECTION (academia.chorke.org)
###############################################################
[nginx-academia-login]
enabled = true
port = http,https
filter = nginx-academia-login
logpath = /home/chorke/sites/academia.chorke.org/current/log/nginx.access.log
maxretry = 5
findtime = 10m
bantime = 1h
###############################################
# 4️⃣ POSTGRESQL PROTECTION
###############################################
[postgresql]
enabled = true
port = 5432
filter = postgresql
logpath = /var/log/postgresql/postgresql-*.log
maxretry = 5
INI