I need to exclude some secret data in my apache log, but I want to keep the log and uri in it. Is it possible to do the following in my access log:
127.0.0.1 - - [27/Feb/2012:13:18:12 +0100] "GET /api.php?param=secret HTTP/1.1" 200 7600 "http://localhost/api.php" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56 Safari/535.11"
I want to replace "secret" with "[FILTERED]" as follows:
127.0.0.1 - - [27/Feb/2012:13:18:12 +0100] "GET /api.php?param=[FILTERED] HTTP/1.1" 200 7600 "http://localhost/api.php" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56 Safari/535.11"
I know that I probably should have used POST to send this variable, but the damage has already been done. I looked at http://httpd.apache.org/docs/2.4/logs.html and LogFormat, but could not find a way to use a regular expression or the like. Any suggestions?
[edit]
DO NOT send sensitive variables as GET parameters if you have a choice.
source share