I am trying to debug an issue with ModSecurity. Using ModSecurity 2.9.2 on Apache 2.4.33. I've simplified the situation as far as possible, but have run into a wall. I'm working within a virtualhost config. Here's what I'm trying to do:
SecAction "pass,setenv:TESTPAGE=1,nolog,id:10001001"
Header always set X-Debug "IsTest" env=TESTPAGE
With no other rules, this should always set the X-Debug header, but it doesn't. To try to figure out why, first I deleted the SecAction and just did this:
RewriteRule .* - [E=TESTPAGE]
Header always set X-Debug "IsTest" env=TESTPAGE
Sure enough, the header was set in that case, so I know headers are working and environment variables can be set/checked. Then I tried this:
SecAction "deny,status:503,setenv:TESTPAGE=1,nolog,id:10001001"
And indeed I got blocked with a 503 http code, so I know the SecAction is being processed. Given those two things, the only possibility is that ModSec is failing to set the environment variable as it should, but I don't know of any reason why that should be the case.
Edit #1
For some reason the 'deny' setting now no longer blocks processing of the page. So I still get the status code set, or if I keep 'deny' but remove the 'status' directive, I get a 403 code, which I assume is the default for 'deny', but the page itself still loads. Not sure if this has the same cause as the environment variable not being set.