Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to log all HTTP request headers with Apache?

Tags:

logging

apache

How to make a record into the logfile the contents of the HTTP request header (all) as received by apache?

Currently my apache combined log format configuration is:

LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" \"%{Cookie}i\"" combined 

I understand that it is possible to do it so:

LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" \"%{Cookie}i\" \"%{heading name}i\" \"%{heading name}i\" \"%{heading name}i\"" combined 

but it is not logical and it is not possible to know which headers will be.

like image 250
Karls Avatar asked Mar 30 '12 17:03

Karls


People also ask

How do I see all HTTP headers?

To view the request or response HTTP headers in Google Chrome, take the following steps : In Chrome, visit a URL, right click , select Inspect to open the developer tools. Select Network tab. Reload the page, select any HTTP request on the left panel, and the HTTP headers will be displayed on the right panel.

Does Apache log post data?

POST data is sent in the request's body, so Apache can't log POST requests by default. You can log POST request details by using dumpio module for Apache, which allows logging of HTTP request body.

What does Apache HTTP server use for logging?

In Linux, Apache commonly writes logs to the /var/log/apache2 or /var/log/httpd directories depending on your OS and Virtual Host overrides. You can also define a LogFormat string after the filename, which will only apply the format string to this file.

How many headers can an HTTP request have?

HTTP does not place a predefined limit on the length of each header field or on the length of the header section as a whole, as described in Section 2.5.


1 Answers

mod_log_forensic is what you want, but it may not be included/available with your Apache install by default.

Here is how to use it.

LoadModule log_forensic_module /usr/lib64/httpd/modules/mod_log_forensic.so  <IfModule log_forensic_module>  ForensicLog ${APACHE_LOG_DIR}/forensic.log </IfModule>  

Note: Your path may vary, such as /usr/lib/apache2/modules/mod_log_forensic.so

like image 198
CrazyPyro Avatar answered Sep 21 '22 08:09

CrazyPyro