Imagine you have a site API that accepts data in the form of GET requests with parameters, or as POST requests (say, with standard url-encoded, &-separated POST data). If you want to log and analyze API calls, the GET requests will be easy, because they will be in the apache log. Is there a simple way to get the POST data in the apache log as well?
(Of course we could log the POST data explicitly in the application, but I'd like to have an configuration-level way that let me not worry about it in code.)
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.
Log Rotation The access log file typically grows 1 MB or more per 10,000 requests.
Use Apache's mod_dumpio. Be careful for obvious reasons.
Note that mod_dumpio stops logging binary payloads at the first null character. For example a multipart/form-data
upload of a gzip'd file will probably only show the first few bytes with mod_dumpio.
Also note that Apache might not mention this module in httpd.conf
even when it's present in the /modules
folder. Just manually adding LoadModule
will work fine.
You can install mod_security
and put in /etc/modsecurity/modsecurity.conf
:
SecRuleEngine On SecAuditEngine On SecAuditLog /var/log/apache2/modsec_audit.log SecRequestBodyAccess on SecAuditLogParts ABIJDFHZ
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