Best way to log POST data in Apache?

前端 未结 8 1407
隐瞒了意图╮
隐瞒了意图╮ 2020-11-27 04:40

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).

8条回答
  •  一个人的身影
    2020-11-27 05:00

    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"}
    

提交回复
热议问题