Customizing Mail-in-a-box part 2

In attempting to block bots, I've gone through several iterations with configuring Modsecurity, Fail2ban and Nginx.

First, I discovered that the mitigation for the invalid (or absent) hostname attack is sufficient for the bots I've encountered so far. The following configuration:

will block requests like the following:

Returning `444`, which is an Nginx specific status code, ensures the connection is closed immediately (preserving server resources). Since these invalid requests are stopped at this level, it doesn't even trigger modsecurity. I also have a rather strict fail2ban jail which will ban offenders at the first request for a whole day:

And the rather basic filter:

So far I only care about `444` since no legitimate request should trigger that status code.

For blacklists, the two projects I'm using are ipset-blacklist[1] and nginx-badbot-blocker[2]. The former uses several RBL's then simply feeds them into ipset while the latter does it at the Nginx level. As the badbot blocker returns a `444` for any bad domain, it integrates well with the above fail2ban configuration.

1: https://github.com/trick77/ipset-blacklist

2: https://github.com/mariusv/nginx-badbot-blocker

Furthermore I utilized both gixy[3], a Nginx configuration static analyzer and the CIS Benchmarks. I added the following to my Nginx configuration:

3: https://github.com/yandex/gixy

The header settings are recommended by OWASP while the buffer size and timeout settings are recommended by the CIS Benchmarks to deal with buffer overflow and DoS attacks respectively. Finally, the conditional is to limit the allowed HTTP verbs to a reasonable set.

Proxied content from gemini://remyabel.flounder.online/2020-01-30-customizing-mailinabox-part-2.gmi (external content)

Gemini request details:

Original URL
gemini://remyabel.flounder.online/2020-01-30-customizing-mailinabox-part-2.gmi
Status code
Success
Meta
text/gemini
Proxied by
kineto

Be advised that no attempt was made to verify the remote SSL certificate.