Re: Selecting back end from host header
> use_backend %[req.hdr(host),lower] Is there anyway to extract the host subdomain to use like this (rather than the full hostname)? I can't see any obvious way to do it from the manual, but perhaps I'm missing something. On 14 November 2015 at 22:14, SLwrote: > @Igor - thanks, I didn't know about that map feature, I think it could be > useful in a number of situations. > > @Baptiste - Ah, it is possible dynamically, that's great - thank you! > > On 14 November 2015 at 22:05, Baptiste wrote: > >> On Sat, Nov 14, 2015 at 3:21 PM, SL 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 >> > >
Re: Selecting back end from host header
> use_backend %[req.hdr(host),lower] Is there anyway to extract the host subdomain to use like this (rather than the full hostname)? I can't see any obvious way to do it from the manual, but perhaps I'm missing something.
Selecting back end from host header
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
Re: Selecting back end from host header
On Sun, Nov 15, 2015 at 1:21 AM, SLwrote: > 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 > > http://blog.haproxy.com/2015/01/26/web-application-name-to-backend-mapping-in-haproxy/
Re: Selecting back end from host header
On Sat, Nov 14, 2015 at 3:21 PM, SLwrote: > 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
Re: Selecting back end from host header
Can maps be used with 'use-server' in listen or backend sections similarly to how it can be used with 'use_backend'? On Sat, Nov 14, 2015 at 1:06 PM Baptistewrote: > On Sat, Nov 14, 2015 at 3:21 PM, SL 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 > >
Re: Selecting back end from host header
@Igor - thanks, I didn't know about that map feature, I think it could be useful in a number of situations. @Baptiste - Ah, it is possible dynamically, that's great - thank you! On 14 November 2015 at 22:05, Baptistewrote: > On Sat, Nov 14, 2015 at 3:21 PM, SL 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 >