问题原文
原帖链接 · Jonesome Reinstate Monica · CC BY-SA 3.0
We have an application server that sometimes hangs. We suspect it is due to a bad request from a client.
Can nginx log the complete request/response (like fiddler captures) to files, so we can see the requests that were sent before the hang?
(We probably need to avoid pcap and that approach and do it all in nginx)
If nginx is not the right tool for this, what (other than a network analyzer) might be?
已采纳解答
原帖链接 · Xavier Lucas · CC BY-SA 3.0
To get the request body sent by visitors, use client_body_in_file_only on; and log the "temporary" file it's written to in the logs by appending var $request_body_file to the log format. "Temporary" files will be located in client_temp directory by default.
You can log request headers $http_<header> too and sent headers with $sent_http_<header>.
If you have request body and headers you should be able to replay it and get the response your visitor had.
Also something like gor should highly be considered so you could replay the traffic on an other environment where you could let nginx write these temporary files without causing IO issues in production (nginx won't purge them with on value that's why It's not that "temporary" in this case).
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
