Hi all,

Le 11/03/2013 23:30, Thomas Heil a écrit :
Hi,

On 03/11/13 20:58, David Coulson wrote:
I am trying to setup HAProxy as a reverse-proxy for a nasty application that 
really wants the Host: header on the backend request to match the hostname of 
the backend system - It's a off-the-shelf app, so there is no opportunity to 
make modifications to this.

So far I've got a rspirep to strip out 301/302 Location headers and put in the 
HAProxy instance hostname, but on the backend I still have to replace Host: 
with the backend server name. With only one backend server and a hard coded 
reqirep header it works, however somehow I need a per-server reqirep 
substitution.
As you allready noticed, you cant do that directly.

You can do it directly by using a trick with the "http-send-name-header" keyword [1], with "Host" as the header name. Then, be sure to name your backend servers with their hostname, and that's it ;-)

Caution : there was a bug in haproxy-1.4, which is only solved in the last snapshot, but it's OK in the 1.5 branch. From the configuration you provided, I guess you're already in 1.5.

Example :
    listen test :8888
        mode http
        option http-server-close

        http-send-name-header Host

        server server1.local 127.0.0.1:80
        server server2.local 127.0.0.1:80

In this example, server1.local and server2.local are the values provided in the Host header.

[1] http://cbonte.github.com/haproxy-dconv/configuration-1.5.html#http-send-name-header

--
Cyril Bonté

Reply via email to