unique_id

Gábor Farkas gabor at nekomancer.net
Mon Jul 18 09:07:08 UTC 2011


hi,

i need something like
http://httpd.apache.org/docs/current/mod/mod_unique_id.html (but for
nginx obviously).

basically i need nginx to generate some kind of
uuid/checksum/something-unique, that it can send to an
upstream-proxied server,
and also put into the logs. the idea is to be able to track the
'lifetime' of a request as it traverses through nginx and into the
upstream server and then back into nginx.

currently i'm using an approach where i generate it in the
upstream-server, and then send it back to nginx in the response
as a header. and then i log it in nginx. this works fine when the
request finishes correctly, but when something crashes
in the upstream-server, and no response reaches nginx, there is no
uuid, so no uuid is written to the nginx logs. so, when
i start to investigate why things went wrong, i find the uuid in the
upstream-server logs, but i cannot match it to a line
in the nginx access logs.

any ideas?

the only thing i could find is to use something like
https://github.com/simpl/ngx_http_set_hash,
and generate a hash from ip_address+timestamp+whatever, and send it to
upstream and log it,
but this means i have to recompile nginx, and still i'm not sure if it
will work or not :)

thanks,
gabor



More information about the nginx mailing list