I'm using OWASP core rule set 3.2.0 set up with ModSecurity 3.0.4 and ModSecurity-nginx.
If I have a rule exclusion like this, in REQUEST-900-EXCLUSION-RULES-BEFORE-CRS.conf
:
SecRule REQUEST_URI "@beginsWith /api.php" \
"id:1015,\
phase:2,\
pass,\
nolog,\
ctl:ruleRemoveById=941160"
How do I also limit this exclusion to a specific hostname? For example, wiki.example.com
.
Using
REQUEST_HEADERS:Host
chained withREQUEST_URI
does the trick, but gets harder to maintain, if there are several sites that either need or don't need the exclusion. Therefore, an alternative solution would be disabling the rules on the Nginx configuration for the virtualhost, instead.It's possible to disable some rules using
modsecurity_rules
inside specificserver
&location
:The same is possible with Apache, too, as some Apache users may later find this question based on its title. With Apache, you can use
SecRuleRemoveById
/modsecurity_rules
directivesinside
VirtualHost
andLocation
orLocationMatch
:or, although not recommended, even with
.htaccess
:The answer is to use
REQUEST_HEADERS:Host
with chain, like this: