How to pass "Host" header from client request to backend server



I created a custom HAProxy load balancing code, that instead of using one of the default algorithms such as round robin, calls a webservice that decides which server to route to. I call from haproxy C code to the webservice using libcurl. That part works. However, I would like to send the “host” header from the client request that reaches HAProxy to this webservice, as a query parameter. But I am not sure how to get the host header from the client request!

I tried using methods like “find_http_header2(“Host”, 4, …)” and variants, as seen in proto_http.c usages. But the Host header never seems to be found, only other headers such as Content-Length, Connection etc.From my browser (Firefox), I used the debugger and the GET http request sent by the browser does have the Host header, so not sure why HAProxy doesn’t receive it.

I am currently using a “listen” configuration but even if I separate in frontend and backend configurations on haproxy.cfg, the issue is still the same. Any ideas?


Hi cgomes -

If this is something you’re doing in a C extension or something, I’d recommend asking on the mailing list. More eyes and more developers live there.

  • Andrew