HAPROXY per domain redirection

haproxyhttp-headersredirection

I'm trying to redirect requests to my load balancer by domain name with acl and hdr_dom, to a separate backend.
The redirection works ok with the first request – 'GET /' (the destination server is a WordPress site) but when the client asks for the assets ('GET /blablabla/style.css' for example) the haproxy doesn't redirect it to the right backend anymore, but to the default one, with .

In the haproxy log I can see the correct host that the request is for (the one that I defined in hdr_dom) but it's like that since the GET request itself is relative (I mean not containing the domain but only from the /blablabla and forth), haproxy doesn't recognize it with the hdr_dom. I'm just guessing here.. Please help…

Best Answer

I have a configuration similar to this one and it works

use_backend webcams if { hdr(host) -i webcams.XX.YY webcams.YY.ZZ }
use_backend spain   if { hdr_dom(host) -i TT.es }
default_backend DEFAULT

Note that this config parses the "Host" header in two different ways: exact host name and domain only, always ignring the case.

Idea: are you parsing the correct part of the header? Only the domain, for example, instead of the whole hostname, or there is a case mismatch...