On Fri, Jan 27, 2017 at 12:10 AM, sendmaildevnull
<sendmaildevn...@gmail.com> wrote:
> I'm trying generate a unique-id-header only if one is not already provided
> in the request. If I provide the header in my request to haproxy I end up
> with duplicate headers, one with auto generated header and another with the
> user provided header. I attempted to use the technique mentioned here
> (http://discourse.haproxy.org/t/unique-id-adding-only-if-header-not-present/67/2)
> and listed below but it is not working for me. Basically, I'm unable to
> check/get value for unique-id-header (e.g. req.hdr(TMP-X-Request-Id)). Any
> ideas?


I have struggled with this one also, and I reached a simple (but
suboptimal) solution:
(A)  Set an `X-HA-Request-Id` header if it doesn't already exist;
(B)  Configure `unique-id-*` as follows:
  unique-id-format %[req.hdr(X-HA-Request-Id)]
  unique-id-header X-HA-Request-Id-2

(I.e. in the end there are two exact headers sent to the backend, with
equal values, either the original value of the `X-HA-Request-Id`
header, or a random one.)


BTW, I always set the request header (if it doesn't already hold a
value) as a random token which would yield 128 bits of entropy, and
doesn't provide any personal identifiable information.

  http-request set-header X-HA-Request-Id
%[rand(4294967295)].%[rand(4294967295)].%[rand(4294967295)].%[rand(4294967295)]
if ...


Hope it helps,
Ciprian.


P.S.:  It sure would be helpful to have some cryptographic
transformation functions like the SHA2 family, HMAC-based functions,
and a cryptographic random function.  :)

Reply via email to