I seem to have written a mini web firewall. I've been watching my self-hosted bl...

@cybervegan@autistics.life

I seem to have written a mini web firewall. I've been watching my self-hosted blog web server's logs, because I wanted to block AI web bots, and I noticed (again) that I get a lot of malware vulnerability scans. My site is static, so they're unlikely to ever "get in" because they all make requests that result in a 404 Not Found, or other 4xx response, but they annoy me and I needed a small, low intensity project to try to get my brain going again.

So I've come up with a very simple Python script that tails the log, looking for 4xx codes. If it sees a known "bad" request, or too many 404s from an address, it firewalls the IP address, and stops it in its tracks.

I need to make it a bit easier to use, and probably collect a list of failed requests to add to the bad list, but I'm quite pleased with it so far. Obviously I'm not Fortinet but it feels good to fight back in even such a tiny way.

#blog #selfHosting #Python #FreeBSD #NGINX