0

I'm trying to set up HAProxy such that it picks a backend based on a header value. But I also want to hide that header from backends.

My config:

defaults
  mode http
  timeout connect 5s
  timeout client 5s
  timeout server 5s 

listen lb
  bind *:1234
  balance hdr(Proxy-Authorization)
  # http-request del-header Proxy-Authorization
  server srv1 192.0.2.1:8080
  server srv2 192.0.2.2:8080
  server srv3 192.0.2.3:8080

With this config Proxy-Authorization is passed down to backends, which I wanted to avoid. If I uncomment http-request del-header Proxy-Authorization it disappears, but also balance hdr(Proxy-Authorization) can no longer see it and starts just doing round-robin.

Is it possible to balance based on a header value and hide it from the backend at the same time?

dnt
  • 3
  • 1
  • `http-request` is processed very early, while `balance` is very late... but I suspect there are other complications here -- unsure, but HAProxy may redistribute requests if one backend goes down, even if the requests wouldn't have gone to the affected backend. I think. You might look at storing the header value in a variable, then using that variable in conjunction with a stick table. I think that could be the more "proper" solution, since your objective seems like it might be related to stickiness rather than balancing. – Michael - sqlbot Jul 28 '19 at 23:19
  • Have you tried `reqdel ^Proxy-Authorization:` in the backend definitions? – wurtel Jul 30 '19 at 12:28
  • @wurtel Yes I tried that, effect is the same as `http-request del-header`: fallback to round-robin. – dnt Jul 31 '19 at 12:48

0 Answers0