Home

Where to install fail2ban?

$$20123
https://lemmy.world/u/anticonnor posted on Mar 29, 2026 19:57

I’ve been doing some selfhosting and want to setup fail2ban for my exposed apps, but am unsure if that should be setup on my router (OpenWRT), on each server that may be exposed, or just in the Caddy container?

My setup right now is: TP-Link router with OpenWRT Lenovo M910q with Proxmox, which hosts the following: - Caddy in a container for reverse proxies to hosted apps - Home Assistant OS in VM#1 - Other apps in docker containers on VM#2

https://lemmy.world/post/44914333
Reply
$$20128
https://lemmy.zip/u/frongt posted on Mar 29, 2026 20:02
In reply to: https://lemmy.world/post/44914333

Don’t modify containers. Send their logs to fail2ban and block things at the edge.

https://lemmy.zip/comment/25570897
Reply
$$20134
https://lemmy.world/u/anticonnor posted on Mar 29, 2026 20:08
In reply to: https://lemmy.zip/comment/25570897

I’m still not sure what this means. Run fail2ban on the router or on each VM? Caddy does have a fail2ban module if it makes more sense to run there?

https://lemmy.world/comment/22936865
Reply
$$20136
https://lemmy.world/u/themachine posted on Mar 29, 2026 20:14
In reply to: https://lemmy.world/post/44914333

If the router is the single point if entry at your edge then I’d run fail2ban on it assuming it can see the traffic

https://lemmy.world/comment/22936961
Reply
$$20137
https://piefed.social/u/nymnympseudonym posted on Mar 29, 2026 20:16
In reply to: https://lemmy.world/post/44914333

Honest question: Why fail2ban? Have you considered crowdsec ?

I used to use the former; I’ve found the latter to be easier to maintain and I like that it shares threats real-time

https://piefed.social/comment/10740973
Reply
$$20138
https://jlai.lu/u/Eirikr70 posted on Mar 29, 2026 20:21
In reply to: https://lemmy.world/comment/22936865

Run it in some place where it can easily read the logs of your apps.

https://jlai.lu/comment/20269333
Reply
$$20164
https://lemmy.world/u/anticonnor posted on Mar 29, 2026 21:03
In reply to: https://piefed.social/comment/10740973

I’ll give it a look. No real reason for fail2ban specifically, it’s just often mentioned as an easy process for beginners.

https://lemmy.world/comment/22937614
Reply
$$20165
https://lemmy.world/u/irmadlad posted on Mar 29, 2026 21:03
In reply to: https://piefed.social/comment/10740973

Honest question: Why fail2ban? Have you considered crowdsec ?

Why not both?

https://lemmy.world/comment/22937616
Reply
$$20167
https://lemmy.world/u/anticonnor posted on Mar 29, 2026 21:04
In reply to: https://lemmy.world/comment/22936961

Thank you! I’ll start there and check that I can easily access the logs.

https://lemmy.world/comment/22937635
Reply
$$20168
https://lemmy.world/u/anticonnor posted on Mar 29, 2026 21:05
In reply to: https://jlai.lu/comment/20269333

Thank you both, I’m starting to get it.

https://lemmy.world/comment/22937646
Reply
$$20182
https://piefed.ca/u/cecilkorik posted on Mar 29, 2026 21:26
In reply to: https://lemmy.world/post/44914333

The simple, maybe unhelpful answer is that fail2ban needs to have two things at once: the logs, and a way to block the network traffic.

Where exactly you want those things to coincide is really up to you, there might only be one point that simultaneously has access to both those things, or there might be multiple points depending on how your systems and services and network is configured, or if you’re in a bad situation you might find you don’t really have any single point where both those things are simultaneously possible, in which case you’ll need to reconfigure something until you do have at least one point where both those things are again coincident.

As far as best practices, I can’t really say for sure, but I know that one of the more convenient ways to run it is usually on the same system, I usually run it outside of docker, on the host, which can pretty easily get access to the container’s logs if necessary, and let fail2ban block traffic on the whole system. For me, any system running any publicly accessible network services that allow password login gets a fail2ban instance.

A whole-network approach where you block the traffic on the firewall is fine too, if that’s what you prefer and what you want to work towards, but it’s probably going to be significantly more complex to set up because now you need to either figure out how to get fail2ban to be able to access your firewall or a way for your firewall to get the logs it needs.

https://piefed.ca/comment/4061204
Reply
$$20191
https://piefed.blahaj.zone/u/irotsoma posted on Mar 29, 2026 21:43
In reply to: https://piefed.social/comment/10740973

I didn’t like crowdsec because of the limits on the free account. For example, I got way more than the 500 max monthly alerts just with one application being protected. So it was difficult to analyze threats. It was easier to set up though. And both serve slightly different use cases.

https://piefed.blahaj.zone/comment/3927415
Reply
$$20244
https://lemmy.blahaj.zone/u/MangoPenguin posted on Mar 29, 2026 23:27
In reply to: https://piefed.blahaj.zone/comment/3927415

You can analyze with either the CLI or log files piped into something like OpenObserve which is what I do. You don’t technically need their dashboard.

https://lemmy.blahaj.zone/comment/19847875
Reply
$$20245
https://lemmy.blahaj.zone/u/MangoPenguin posted on Mar 29, 2026 23:27
In reply to: https://lemmy.world/comment/22937616

Crowdsec does everything fail2ban does so not much point.

https://lemmy.blahaj.zone/comment/19847881
Reply
$$20250
https://piefed.social/u/sepi posted on Mar 29, 2026 23:38
In reply to: https://lemmy.world/post/44914333

On the computer

https://piefed.social/comment/10743074
Reply
$$20305
https://lemmy.world/u/irmadlad posted on Mar 30, 2026 02:04
In reply to: https://lemmy.blahaj.zone/comment/19847881

In my thinking, redundancy, defense in depth…..maybe? May be overkill. I run them both with no issues.

https://lemmy.world/comment/22941054
Reply
$$20327
https://lemmy.dbzer0.com/u/superglue posted on Mar 30, 2026 02:44
In reply to: https://lemmy.world/post/44914333

Linuxserver SWAG container has fail2ban and Nginx built into the same container. It can read your nginx logs and modify the servers firewall rules to ban them.

https://lemmy.dbzer0.com/comment/25245108
Reply