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).
Though It's late to answer. This module can do: https://github.com/danghvu/mod_dumpost
Not exactly an answer, but I have never heard of a way to do this in Apache itself. I guess it might be possible with an extension module, but I don't know whether one has been written.
One concern is that POST data can be pretty large, and if you don't put some kind of limit on how much is being logged, you might run out of disk space after a while. It's a possible route for hackers to mess with your server.
I would do it in the application, actually. It's still configurable at runtime, depending on your logger system, of course. For example, if you use Apache Log (log4j/cxx) you could configure a dedicated logger for such URLs and then configure it at runtime from an XML file.
You can also use the built-in forensic log feature.
You can use [ModSecurity][1]
to view POST data.
Install on Debian/Ubuntu:
$ sudo apt install libapache2-mod-security2
Use the recommended configuration file:
$ sudo mv /etc/modsecurity/modsecurity.conf-recommended /etc/modsecurity/modsecurity.conf
Reload Apache:
$ sudo service apache2 reload
You will now find your data logged under /var/log/apache2/modsec_audit.log
$ tail -f /var/log/apache2/modsec_audit.log
--2222229-A--
[23/Nov/2017:11:36:35 +0000]
--2222229-B--
POST / HTTP/1.1
Content-Type: application/json
User-Agent: curl
Host: example.com
--2222229-C--
{"test":"modsecurity"}
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