问题原文
原帖链接 · zaphoyd · CC BY-SA 4.0
I have an HAProxy load balancer that I would like to use to tag requests with a unique id (X-Unique-ID header) so that I can correlate events between logs in multiple systems.
HAProxy has a feature for doing this with the unique-id-format directive. The documentation explains that this uses only the syntax from the logging system and goes on to suggest that you use things like the client and server ip addresses, timestamps, etc to build something that is likely to be unique.
I am wondering if it is possible to generate a random (version 4) UUID (or something similar) for each request rather than generating one with potentially sensitive client information like IP address and request time.
已采纳解答
原帖链接 · micmax93 · CC BY-SA 4.0
Starting from HAProxy 2.0 uuid() function is available.
So this should do exactly what you need:
unique-id-format %[uuid()]
unique-id-header X-Unique-ID
One advantage to using unique-id-header instead of http-request set-header, is that you can set it in defaults section.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
