How do you log the response body (not request body) in nginx? I could not find such a variable in any of the modules (only the request body).

We are using nginx as a reverse proxy/loadbalancer and would like to parse our API requests & responses from nginx logs.

Thank you!

  • I don't know anything like mod_security for Apache, that allows such type of logging. Maybe a 3Party Module? – grosshat May 22 '12 at 12:56
  • serverfault.com/a/479123 might answer the question. – kojo Nov 7 '13 at 10:38

You could log the headers using $upstream_http_HEADER. Doesn't seem like there is a variable for the response body though but I'm not surprised - this part would be optimized.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.