HAProxy community

How to set http-request set-header for just specific backends?


#1

Hi,
I have defined a lua header in haproxy config to add a header (X-Request-Id) to all incoming requests, but now I need to exclude one of the backends!

Here is my related config file:

global
    ...
    lua-load /var/lib/haproxy/uuid_v4.lua
    ....

frontend http-https
    ...
    http-request set-header X-Request-Id %[lua.uuid_v4]
    ...
 
backend app_aa
    server swarm-worker_10.10.40.36 10.10.40.36:64037 check

 
backend app_bb
    server swarm-worker_10.10.40.36 10.10.40.36:64038 check

backend app_cc
    server swarm-worker_10.10.40.36 10.10.40.36:64039 check

My question is how can I exclude backend app_bb?
Can I somehow set http-request set-header just for app_aa and app_cc NOT the app_bb?

Thank you


#2

Either move it to the actual backends or use ACL to exclude it, just like as you use it when selecting the backend with use_backend.