Copy · paste · reload

Fail2ban configs you can actually paste.

A library of ready-to-use jail.local blocks and filter rules for SSH, Nginx, Apache, mail servers and WordPress — copy the block, reload Fail2ban, done. Every recipe says exactly where each line goes and how to confirm it works.

15 recipes

Why this exists

Fail2ban answers are scattered. The config you need isn't.

Search for a single jail — Nginx bad-bot blocking, a WordPress login filter, the right banaction for nftables — and you land on a six-year-old blog post, a Reddit thread, or a gist with no context. fail2ban-recipes.pages.dev collects the configs that actually work into one place: each recipe is a focused, copy-paste answer to one real task, with the exact file path, the reload command, and how to verify the jail is catching attempts.

How it works

Find the jail, paste it, reload

  1. Pick a recipe. Browse the cards above or the full recipe list, grouped by service.
  2. Copy the exact block. Every config block has a one-click copy button — no retyping, no guessing the directive names.
  3. Reload and verify. Each recipe ends with the fail2ban-client command to confirm the jail is active and banning.

FAQ

Frequently asked questions

Are these Fail2ban configs free?

Yes. Every recipe on fail2ban-recipes.pages.dev is free to read and copy, with no account, paywall, or sign-up. Some outbound links (for example to VPS or hosting providers) may be affiliate links, which never change the price you pay.

Where do I paste these configs?

Jail definitions go in /etc/fail2ban/jail.local (never edit jail.conf — it is overwritten on upgrade). Custom filters go in /etc/fail2ban/filter.d/<name>.conf. After any change, reload with "sudo fail2ban-client reload". The Basics recipes walk through this.

Will Fail2ban lock me out of my own server?

It can if you trip your own jail (e.g. a few failed SSH logins). Always whitelist your own IP with ignoreip before enabling jails, and keep a second console open. There is a dedicated recipe for whitelisting and for unbanning an IP.

My distro has no /var/log/auth.log — do these still work?

Yes. On systemd distros (Debian 12, Ubuntu 22.04+, Fedora, etc.) logs live in the journal, not /var/log/auth.log. Set backend = systemd on the jail — the "Fail2ban on systemd journald" recipe covers this exactly.

iptables or nftables?

Both work. Modern distros default to nftables; older ones use iptables. Each recipe notes the banaction to use, and there is a dedicated recipe for switching Fail2ban to the nftables banaction.

How do I know a jail is actually working?

Run "sudo fail2ban-client status" to list active jails and "sudo fail2ban-client status <jail>" to see banned IPs and matched lines. Before enabling, test your filter against a real log with fail2ban-regex — both are covered in the Basics recipes.