• Our team is looking to connect with folks who use email services provided by Plesk, or a premium service. If you'd like to be part of the discovery process and share your experiences, we invite you to complete this short screening survey. If your responses match the persona we are looking for, you'll receive a link to schedule a call at your convenience. We look forward to hearing from you!
  • We are looking for U.S.-based freelancer or agency working with SEO or WordPress for a quick 30-min interviews to gather feedback on XOVI, a successful German SEO tool we’re looking to launch in the U.S.
    If you qualify and participate, you’ll receive a $30 Amazon gift card as a thank-you. Please apply here. Thanks for helping shape a better SEO product for agencies!

Issue How to properly configure Fail2Ban for ModSecurity in Plesk with NGINX?

Jürgen_T

Regular Pleskian
Server operating system version
Ubuntu 22.04.5 LTS
Plesk version and microupdate number
Plesk Obsidian 18.0.67 Update #3
Hello everyone,

I have successfully installed ModSecurity with NGINX on my Plesk server. Now, I want to use Fail2Ban to permanently block IPs of attackers that ModSecurity identifies.

However, after installation, I noticed that the configuration files for ModSecurity were missing in Fail2Ban. Additionally, the plesk-modsecurity service could not be activated.

Could someone provide the original content of the Plesk Fail2Ban configuration files for ModSecurity? I would like to restore them and ensure they work correctly with my NGINX setup.

Thanks in advance!
 
Jail
Code:
[plesk-modsecurity]
enabled = true
filter = plesk-modsecurity
action = iptables-multiport[name="plesk-modsecurity", port="80,443,7080,7081", protocol="tcp,udp"]
logpath = /var/log/modsec_audit.log
maxretry = 4

Filter
Code:
[Definition]
failregex = ^(?:\[.*?\]\s\S*)\s<HOST>\s
ignoreregex = ^\[.*?\]\s\S*\s<HOST>\s.*\s\1
    collection_store
    collections_remove_stale
 
Thank you for your quick response! Unfortunately, Fail2Ban didn’t work because it couldn’t find any IPs in the ModSecurity audit log files, and ModSecurity itself stopped logging unexpectedly. As a result, I had to remove it again. Additionally, switching from the selected Apache rule set (2.9) to my proxy NGINX rule set (3.0) didn’t work either. I’ll give ModSecurity another try once it proves to be more stable in my environment.
 
@Kulturmensch

Off topic, but DID YOU managed to get Nginx work with ModSecurity? I set it up, see the setup and all is in there, but there is no filtering, reporting, blocking or whatsoever.
 
Off topic, but DID YOU managed to get Nginx work with ModSecurity? I set it up, see the setup and all is in there, but there is no filtering, reporting, blocking or whatsoever.
Unfortunately, not yet. The first time I tried it, it worked for a short time, but then ModSecurity stopped logging, and after uninstalling it, NGINX also stopped working, so I had to run my websites on Apache for a while. The second time I tried it, a month ago, it worked better, and ModSecurity worked for a while, but when I tried to secure ModSecurity with fail2ban, it stopped logging again, so I had to uninstall it again. This is the current status.
 
Unfortunately, not yet. The first time I tried it, it worked for a short time, but then ModSecurity stopped logging, and after uninstalling it, NGINX also stopped working, so I had to run my websites on Apache for a while. The second time I tried it, a month ago, it worked better, and ModSecurity worked for a while, but when I tried to secure ModSecurity with fail2ban, it stopped logging again, so I had to uninstall it again. This is the current status.
Thanks for the feedback. This is no good news for Nginx with ModSecurity.
 
Back
Top