Java – nginx: when nginx is used as the reverse proxy, can the response header be captured in the access log?
We use nginx as a reverse proxy to control and record access to clojure (Java) web service applications
We can use nginx to generate access_ Log and capture the incoming header file Our clojure application records activity through log4j The trouble is, we can't put access_ The entries in the log match the entries generated by the application
The application responds to access by sending a response header and body We are free to change these response headers My original idea was to generate a UUID corresponding to each web service request and send it back to the user in the reply header x-uuid My idea is that I can create a custom log_ Format to capture this response:
log_format lt-custom '$remote_addr - $remote_user [$time_local] ' '"$request" $status $body_bytes_sent ' '"$http_referer" "$http_user_agent" $request_time $http_x_uuid';
It looks like nginx can capture headers in incoming requests instead of outgoing replies (I verified this by replacing $http_x_uuid with $http_content_type)
So! Is there any way to bind my access by using nginx to capture outgoing reply headers_ Log entities and my log4j entries? Is there a better way? I'd rather not rely on users to generate their own UUID
Thank you.
Solution
$http_ x_ UUID is the header sent by the client
http://wiki.nginx.org/HttpUpstreamModule#.24upstream_http_.24HEADER