I made some changes to my config as per this suggestion:
SecAction \
"id:901321,\
phase:1,\
pass,\
t:none,\
nolog,\
initcol:global=global,\
initcol:ip=%{x-forwarded-for}_%{tx.ua_hash},\
setvar:'tx.real_ip=%{x-forwarded-for}'"
But nothing seems to happen. I noticed that my apache error_log was using the default error log format and logging everything as 127.0.0.1.
So I changed my ErrorLogFormat
to:
ErrorLogFormat "[%{u}t] [%-m:%l] [pid %P:tid %T] %7F: %E: [client\ %{X-Forwarded-For}i] %M% ,\ referer\ %{Referer}i"
That made my logs better, but ModSecurity is still not doing any blocking. What's weird is that most of the ModSec logs in the apache error_log have an extra client IP section in them:
[Wed May..2019] [err] [pid X:tid X] [client XXX.XX.XX.XXX] [client 127.0.0.1] ModSecurity: Warning...
I have no idea where the extra [client 127.0.0.1]
is coming from - I know it's definitely only doing this for ModSecurity logs in the error_log.
It seems like either ModSecurity is either constantly trying to block 127.0.0.1 or just not blocking anything..
So how can I get ModSecurity to block using the X-Forwarded-For
header?
NOTE
- I do have
SecRuleEngine On
set properly. - Versions: Apache 2.4, ModSecurity 2.9, OWASP 3