HTTP protocol violation protection Common web attacks Bots, crawlers, malicious activity protection Trojan protection Information leakage protection Cross Site Scripting attacks SQL injection attacks

Do you agree? In my previous post, I explained how to install Nginx and Mod Security and as promised here is how you can configure them with OWASP CRS for better security. ModSecurity is open source Web Application Firewall (WAF), and by default, it’s configured to detect only. That means you need to enable the necessary configuration (as following) to start protecting your websites.

Download ModSecurity CRS

Download latest CRS zip file from the following link and transferred to the server

https://github.com/SpiderLabs/owasp-modsecurity-crs/zipball/master

unzip the file

Copy following to nginx conf folder

Configure Nginx to Integrate OWASP ModSecurity CRS

Since you have decided to use OWASP CRS, you need to merge the conf file included in SpiderLabs OWASP CRS, which you just copied (modsecurity_crs_10_setup.conf.example ) under nginx folder. Nginx doesn’t support multiple ModSecurityConfig directives like Apache, so you need to put all rules conf together in a single file. Let’s do it…

Add base_rules & modsecurity_crs_10_setup.conf.example to modsecurity.conf file

You also need to copy all *.data file to nginx conf folder Quick verification: Ensure you have added ModSecurityEnabled and ModSecurityConfig directive in nginx.conf file under location. If not, add them like below.

Restart Nginx

By doing above all means, you have successfully integrated OWASP CRS in Mod Security on Nginx. It’s time to do the little essential tweaking.

Configuring OWASP Core Rule Set to Start Protecting

In this section, all modifications will be in modsecurity.conf file so remembers to take a backup. First thing first

Enable Audit Logging

It’s essential to generate logs, so you know what’s being blocked. Add SecAuditLog directive if doesn’t exist. Restart Nginx, and you will see the log file generated

Enable Security Rule Engine

Begin Mod Security protection by enabling rule engine as below

Enable Default Action as Deny

Configure default action as “block” for any request matching with the rules. Above three configurations is essential and now ModSecurity is ready to execute the action and protect. Here is one more configuration you may like.

Change Server Header Banner

Default Nginx configuration will expose server information with its version, which is highly recommended to mask it if you are working in a PCI-DSS environment. You may also do this without Mod Security as explained here. Default header:

You can do this quickly by adding a line. And now it looks like:

I hope above instruction helps you in integrating OWASP Core Rule Set with Nginx web server for better protection.

How to Implement ModSecurity OWASP Core Rule Set in Nginx - 26How to Implement ModSecurity OWASP Core Rule Set in Nginx - 5How to Implement ModSecurity OWASP Core Rule Set in Nginx - 41How to Implement ModSecurity OWASP Core Rule Set in Nginx - 15How to Implement ModSecurity OWASP Core Rule Set in Nginx - 91How to Implement ModSecurity OWASP Core Rule Set in Nginx - 11How to Implement ModSecurity OWASP Core Rule Set in Nginx - 43How to Implement ModSecurity OWASP Core Rule Set in Nginx - 27How to Implement ModSecurity OWASP Core Rule Set in Nginx - 89How to Implement ModSecurity OWASP Core Rule Set in Nginx - 96How to Implement ModSecurity OWASP Core Rule Set in Nginx - 32How to Implement ModSecurity OWASP Core Rule Set in Nginx - 81How to Implement ModSecurity OWASP Core Rule Set in Nginx - 23How to Implement ModSecurity OWASP Core Rule Set in Nginx - 79How to Implement ModSecurity OWASP Core Rule Set in Nginx - 34How to Implement ModSecurity OWASP Core Rule Set in Nginx - 33How to Implement ModSecurity OWASP Core Rule Set in Nginx - 75How to Implement ModSecurity OWASP Core Rule Set in Nginx - 50How to Implement ModSecurity OWASP Core Rule Set in Nginx - 46How to Implement ModSecurity OWASP Core Rule Set in Nginx - 87How to Implement ModSecurity OWASP Core Rule Set in Nginx - 49How to Implement ModSecurity OWASP Core Rule Set in Nginx - 86How to Implement ModSecurity OWASP Core Rule Set in Nginx - 66How to Implement ModSecurity OWASP Core Rule Set in Nginx - 90How to Implement ModSecurity OWASP Core Rule Set in Nginx - 32