You are correct that rules file uses Apache-specific <LocationMatch> directives.  The idea is that you don't want to inject anti-CSRF tokens into all responses.  This allows the user to defined directories, etc.. Where they want to use it.  

If you are running on Nginx you should be able to use the Location directive syntax here -

Ryan Barnett

Lead Security Researcher, SpiderLabs



From: Madhumita Mitha <>
Reply-To: "" <>
Date: Monday, March 24, 2014 9:22 AM
To: "" <>
Subject: [mod-security-users] CSRF support in modsecurity + Nginx


I am using nginx 1.4 and modsecurity 2.7.7

Apart from the base rules I am trying to use the "optional_rules/modsecurity_crs_43_csrf_protection.conf" in nginx.

But when i start the nginx with the above said rules i get the following error "Unknown command in config: <LocationMatch " and the nginx refuses to start

When i  did searched for the info, one of the sites says the LocationMatch(Apache directive) support is not there for IIS and it will be provided shortly

Does this hold true for nginx as well ?

And if i comment out LocationMatch, nginx starts properly and if i do so then i fear i may not be able to add the CSRF support with nginx+modsecurity

Or is it any particular segment that i can comment out in the file "optional_rules/modsecurity_crs_43_csrf_protection.conf" and add CSRF support

Please help



This transmission may contain information that is privileged, confidential, and/or exempt from disclosure under applicable law. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or use of the information contained herein (including any reliance thereon) is strictly prohibited. If you received this transmission in error, please immediately contact the sender and destroy the material in its entirety, whether in electronic or hard copy format.