tofu's blog

I'm running fail2ban on my reverse proxy to block IPs that are looking for things they aren't supposed to look for. It's a rather basic setup, checking my nginx logs.

I've moved Home Assistant to local only after having it exposed for a while and since realized that the Home Assistant Companion app checking Home Assistant while abroad without enabled VPN gets me thrown into jail. Since I'm not the only HA user in this household, I didn't want to configure all the apps to do that at home only.

Fortunately, fail2ban has a function for exactly this, ignoreregex. Just tell it which lines to ignore. I copied /etc/fail2ban/filters.d/nginx-forbidden.conf to /etc/fail2ban/filters.d/nginx-forbidden-local.conf, added the following line and then configured jail.local to use the new conf instead.

ignoreregex = request: "[A-Z]+ /(api/websocket|auth/token)[ ?"]

Restart fail2ban, unban the current mobile IP or get a new one and the phone stays free! Neat simple solution for that case. I'll have to monitor if more paths need to be added, but these were revealed in the logs.

PS. /api/webhook/ is allowed from remote to update sensor data, otherwise it would need to be ignored as well.

Reactions

How to interact with this page

Webmentions

To interact via Webmentions, send an activity that references this URL from a platform that supports Webmentions, such as Lemmy, WordPress with Webmention plugins, or any IndieWeb-compatible site.

ActivityPub

⭐ 1
Jay 🌺 is crashing ⭐