Apache – How to Log Response Header and Body

apache-2.2http-headerslogging

I need to determine whether the server (Apache 2) is returning the full contents of a page along with its correct header or not. I have a PHP-script that is executed successfully, but the browser is getting only half of the html content, it's simply cut off.

The client infrastructure is pretty complicated, using Novell BorderManager Proxys and stuff. To ensure the server is doing its job fine I want to log both header and body of the reponse.

How can I achieve this? I looked into the mod_log_config module of apache (which is already installed and ready to be used), but honestly I didn't quite manage to configure it to output header and body somewhere.

edit: I managed to log the header with


LogFormat "%h %l %u %t \"%r\" %>s %b \"%{HEADER_NAME}o\"" common2

CustomLog /var/log/apache2/response.log common2

But unfortunately the mod_log_config formats don't support the whole content body.

Update: I stumpled accross mod_dumpio which seems to do exactly that, but I can't get it to work so far 🙁

Can anyone help?

Best Answer

You can do this via mod_security, see the Documentation about Audit Log data format.