I'm trying to sanitise my apache logs of sensitive data as it's passed around in query string parameters. I'm aware this is not good, it cannot be changed.
Following from this question: https://stackoverflow.com/a/9473943/1046387
This is in my apache.conf
CustomLog "|/bin/sed -u -E s/'api_key=[^& \t\n]*'/'api_key=\[FILTERED\]'/g >> /var/log/apache2/access.log" combined
I've been getting this error:
AH00106: piped log program '/bin/sed -u -E s/'api_key=[^& \\t\\n]*'/'api_key=\\[FILTERED\\]'/g >> /var/log/apache2/access.log' failed unexpectedly
/bin/sed: -e expression #1, char 14: unterminated `s' command
Despite being able to run the command on the box directly:
$ echo "api_key=343" | /bin/sed -u -E s/'api_key=[^& \t\n]*'/'api_key=\[FILTERED\]'/g
api_key=[FILTERED]
Seems like apache isn't handing over the command to sed
properly so it's missing some of the arguments. Some problem with escape sequences or something?