• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

Resolved What is the best way to configure NGINX ModSecurity?

othmaqsa

Regular Pleskian
Server operating system version
Ubuntu 20.04.5 LTS
Plesk version and microupdate number
18.0.49
Hello,

What is the best way to configure Modsecurity ? I use only NGINX.

Thank you.
 
Please check the documentation here:
Hello,

Thank you for your message.

I've read this before, but the confusion is that in the documentation:
Apache (ModSecurity 2.9) (recommended).
Nginx (ModSecurity 3.0).
Note: Switching to Nginx (ModSecurity 3.0) may affect your existing applications. We recommend trying ModSecurity 3.0 out on a test server before switching your production environment to that version.


In my case, I use only NGINX only (proxy mode disabled), I need to choose the recommended setting or go Nginx (ModSecurity 3.0) ?
 
If you haven't used ModSecurity before then you should go for ModSecurity 3.0 with nginx and run it in "Detection Mode" only for a while and analyse the logs it produces.

Once you're sure that no legitimate requests would be blocked then you can switch to "On" (blocking mode).
 
If you haven't used ModSecurity before then you should go for ModSecurity 3.0 with nginx and run it in "Detection Mode" only for a while and analyse the logs it produces.

Once you're sure that no legitimate requests would be blocked then you can switch to "On" (blocking mode).
Got it, since it's the first time I use ModSecurity, I'll enable ModSecurity 3.0 with nginx.

Another question: Can I see the Logs with the option Detection Mode ? If yes, where can I see it ?
 

Have a look at the log files section here
@Monty Last questions please: I would like to know, please, the average consumption (CPU/RAM) ? In general, can ModSecurity cause cpu/ram spikes during use?
 
ModSecurity will have a CPU impact, yes. But with a "normal" amount of rules this impact should be very small, close to negligible. To see the impact, record your CPU/RAM usage before activating ModSecurity and then compare it with ModSecurity enabled.

For further tuning and optimization of ModSecurity: ModSecurity Performance Recommendations
 
Back
Top