Logging POST data from $request_body

前端 未结 7 1560
日久生厌
日久生厌 2020-11-27 10:52

I have my config setup to handle a bunch of GET requests which render pixels that work fine to handle analytics and parse query strings for logging. With an additional third

7条回答
  •  庸人自扰
    2020-11-27 11:46

    This solution works like a charm (updated in 2017 to honor that log_format needs to be in the http part of the nginx config):

    log_format postdata $request_body;
    
    server {
        # (...)
    
        location = /post.php {
           access_log  /var/log/nginx/postdata.log  postdata;
           fastcgi_pass php_cgi;
        }
    }
    

    I think the trick is making nginx believe that you will call a cgi script.

提交回复
热议问题