On Sat, Nov 14, 2015 at 3:21 PM, SL <bgs...@gmail.com> wrote: > Hi, > > We have quite a large number of backends, and are selecting which back end > to use based on the host specified in the request. (Note these are not > loadbalanced, we have to target them individually). > > Currently we are doing this with ACLs, e.g. for each: > > acl svr1_request hdr_beg(host) -i svr1 > > then: > > use_backend svr1 if svr1_request > > (An example request host in this case would be svr1.example.com) > > Using ACLs like this means that we have a large number of repeated ACLs and > use_backends. It's a bit cumbersome, difficult to maintain, and I suspect > not very efficient. > > Is there a better way to do this? What would be ideal, is some way to take > the subdomain of the request host, and simply select a backend whose name > matched, but I don't know of any way to do that. Is such a thing possible? > > Thank you > > S >
Hi, As Igor stated, you can use content from this blog article: http://blog.haproxy.com/2015/01/26/web-application-name-to-backend-mapping-in-haproxy/ very usefull if you want to map many host header to the same backend. If you want a single host header per backend, then, simply use use_backend %[req.hdr(host),lower Then each backend must use the host header as the backend name and you're done, dynamic routing with a single use_backend rule, whatever the number of backends you have. Baptiste