I ran into the following problem:
When dynamically rewriting the HTTP Host header with
http-send-name-header Host haproxy seems to mess up HTTP Response headers.
Doing so works fine when using nginx and
proxy_set_header Host $upstream_addr;
What I need to arrive at target-machine:1234 is:
Host: target-machine:1234 instead of
We have a customer installation where only 32bit JVMs can be run, hence we are spawning n instances of the same application on n different ports:
target-machine:8766 target-machine:8767 target-machine:8768 target-machine:8769
And we do have a balancer running on a dedicated
The clients have to be balanced based on IP (a legacy issue of the software we use).
Now we come to the ugly part: the application we intend to use, relies on the
HTTP Host header field, as some operations cause it to send an internal request.
In our current setup this internal request goes to the load balancer, which in turn sends it to one of the target machines, but necessarily to the target machine it originated from.
I used nginx with the Upstream Module before (but we can not anymore, as another must for this software is that HTTP Posts should not be cached by the proxy as its upload progress meter depends on this (sigh...)) and could solve this issue by adding:
proxy_set_header Host $upstream_addr;, yet nginx does not support upload streaming.
I did discovered the
http-send-name-header Host which probably does exactly what I need it to do (see my haproxy.cfg here) but leads to another problem that immediately disappears when I change the line to
The directive adds the right server name to the header, but it seems to mess with the proxied requests as jetty closes the streams prematurely and throws
org.mortbay.jetty.EofException as well as .
What I need is a Host header like:
To the browser this problem illustrates as in the following Screenshot (the size of the sent content differs from nearly complete to only a few KB).
It immediately works when I do not change the Host Header, yet it works if I change the host header to the exact same value but use nginx.
This really leaves me puzzled. If I can assist you with any more information, let me know.