So we have X-Forwarded-For enabled on our SLBs which is working, and I've got correct logging working via the link here, which says to use this SetEnvIF statement.
The problem we are running into is, the SLBs also check ever 5seconds via a GET /health.html file, which is filling up our logs. I was able to find a way to get apache2 to stop logging specific files, however I cannot seem to find a way to do both X-Forward-For and Don't Log specific files.
This was my last attempt, when I read a blog saying you could use multiple Env and sepearate them by a ',' which didn't owrk :(.
#logs
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" proxy
SetEnvIf X-Forwarded-For "^.*\..*\..*\..*" forwarded
SetEnvIf Request_URI "^/health\.html$" dontlog
CustomLog "/www/logs/access.log" combined env=!forwarded,!dontlog
CustomLog "/www/logs/access.log" proxy env=forwarded
I appreciate everyones help.
Thank you for your time.
For your case it should be:
CustomLog /www/logs/access.log combined expr=(reqenv('forwarded')=='no'&&reqenv('dontlog')=='no')
CustomLog /www/logs/access.log proxy expr=(reqenv('forwarded')=='yes')
The last one can be an env
but I left as a expr
for a 'yes'
example.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With