Guides

fail2ban integration guides

Complete, tested setups for the services people most often protect with fail2ban. Each guide gives you the filter, the jail, the log path, a test command and the gotchas specific to that service.

Updated 3 min readChecked against fail2ban 1.1.1

Every guide below follows the same pattern: find the log line a failed login or attack produces, match it with a filter (stock or custom, tested with fail2ban-regex), enable a jail in /etc/fail2ban/jail.local or jail.d/, make sure the ban lands where the traffic actually flows, and verify with fail2ban-client status <jail>. If fail2ban isn't installed yet, start with install fail2ban.

SSH and the system#

Web servers and reverse proxies#

Self-hosted apps#

Mail and VoIP#

VPN#

Firewalls and ban actions#

Operations and integrations#

Which guide do I need?#

  • Your service runs in Docker (NPM, Vaultwarden, Nextcloud AIO, Jellyfin…): read the app's guide and Docker containers. A ban in the default INPUT chain doesn't stop traffic Docker forwards to a container.
  • Your site is behind Cloudflare or another proxy: fail2ban must see the visitor's address, not the proxy's. Fix that first; see Cloudflare and fail2ban bans the proxy IP.
  • On Ubuntu 24.04: the package sets backend = systemd for all jails, so every jail that reads a log file needs backend = auto — all examples in these guides include it.
  • No guide for your app? Write a filter for its log line with the filter generator, test it, and follow writing a custom filter. The jail.local generator builds the jail.

FAQ#

How do I protect a new service with fail2ban?#

Find the log line the service writes on a failed login and confirm it contains the client IP. Write a filter whose failregex matches that line with <HOST> or <ADDR>, test it with fail2ban-regex <logfile> <filter>, then add a jail with enabled = true, the logpath, the port and backend = auto, and reload fail2ban.

Why does fail2ban ban IPs but my Docker app is still reachable?#

Docker forwards published ports to containers through the FORWARD chain, while fail2ban bans in INPUT by default. Use an iptables action with chain = DOCKER-USER, or an nftables chain on the forward hook, for every jail that protects a container.

Spotted something wrong or out of date? Tell us — every page is checked against the current fail2ban release.