Logging POST data from $request_body

前端 未结 7 1481
日久生厌
日久生厌 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:54

    I had a similar problem. GET requests worked and their (empty) request bodies got written to the the log file. POST requests failed with a 404. Experimenting a bit, I found that all POST requests were failing. I found a forum posting asking about POST requests and the solution there worked for me. That solution? Add a proxy_header line right before the proxy_pass line, exactly like the one in the example below.

    server {
        listen       192.168.0.1:45080;
        server_name  foo.example.org;
    
        access_log  /path/to/log/nginx/post_bodies.log post_bodies;
        location / {
          ### add the following proxy_header line to get POSTs to work
          proxy_set_header Host $http_host;
          proxy_pass   http://10.1.2.3;
        }
    }
    

    (This is with nginx 1.2.1 for what it is worth.)

    0 讨论(0)
提交回复
热议问题