Hi,
Le 26/01/2017 à 23:10, sendmaildevnull a écrit :
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?
frontend public
bind *:80
unique-id-format %{+X}o\ %ci:%cp_%fi:%fp_%Ts_%rt:%pid
unique-id-header TMP-X-Request-Id
default_backend ui
backend ui
http-request set-header X-Request-Id %[req.hdr(TMP-X-Request-Id)]
unless { req.hdr(X-Request-Id) -m found }
http-request del-header TMP-X-Request-Id
Instead of using "unique-id-header" and temporary headers, you can use
the "unique-id" fetch sample [1] :
frontend public
bind *:80
unique-id-format %{+X}o\ %ci:%cp_%fi:%fp_%Ts_%rt:%pid
default_backend ui
backend ui
http-request set-header X-Request-Id %[unique-id] unless {
req.hdr(X-Request-Id) -m found }
[1]
http://cbonte.github.io/haproxy-dconv/1.7/configuration.html#7.3.6-unique-id
--
Cyril Bonté