Discussion:
HAProxy's equivalent to ProxyPreserveHost variable behavior
Michael Bode
2011-08-25 15:19:04 UTC
Permalink
I have been running haproxy with great success for a while, however I have
run into a problem I simply cannot figure. Logging into Atlassian's Bamboo
and Confluence behind a proxy with SSL termination at the HAProxy/Stunnel
combo will redirect to a http connection. I put the same sites behind Apache
mod_proxy as a test case. When I toggle mod-proxy's ProxyPreserveHost On, I
can re-create this same behavior using Apache as reverse proxy. When the
value is Off, the websites act as desired and toggling back to http doesn't
happen.

So I want to pass the hostname as requested to these two servers, but I
cannot find the equivalent variable of ProxyPreserveHost for Haproxy to turn
off. I tried http_proxy on the backend to no avail.

Michael Bode
Chief Operations Officer
Bohemia Interactive Simulations
Willy Tarreau
2011-08-27 12:24:12 UTC
Permalink
Post by Michael Bode
I have been running haproxy with great success for a while, however I have
run into a problem I simply cannot figure. Logging into Atlassian's Bamboo
and Confluence behind a proxy with SSL termination at the HAProxy/Stunnel
combo will redirect to a http connection. I put the same sites behind Apache
mod_proxy as a test case. When I toggle mod-proxy's ProxyPreserveHost On, I
can re-create this same behavior using Apache as reverse proxy. When the
value is Off, the websites act as desired and toggling back to http doesn't
happen.
So I want to pass the hostname as requested to these two servers, but I
cannot find the equivalent variable of ProxyPreserveHost for Haproxy to turn
off. I tried http_proxy on the backend to no avail.
It's sad that your application does not work with the correct host field,
because this means it will never be able to work in a virtual server
environment. That's why Apache added the ProxyPreserveHost feature, BTW.

What you can do in haproxy to mimmic this (usually undesired) behaviour
is to simply rewrite the host header to the value your application
expects instead of the correct one. For instance :

reqirep ^Host: Host:\ my-internal-hostname

Note: most of the servers who don't accept valid host names are fine
with 127.0.0.1 or "localhost" in the host name. You might want to try
this, because at least it will save you from managing one parameter :

reqirep ^Host: Host:\ 127.0.0.1

Anyway, it would be better to see how to configure or fix the application
to accept requests for the public hostname instead of rewriting it and
losing the information along the chain.

Hoping this helps,
Willy

Loading...