Hi Rajat,
On Tue, May 06, 2014 at 07:34:34PM -0400, Rajat Chopra wrote:
> Hi!
> The new feature to dynamically select a backend has been going great for
> me.
> I use it like this and it all works like a charm :
>
> use_backend bk_%[hdr(host),host_to_backend.mapfile] if TRUE
>
>
> Now I need help with a situation. Some of the servers meant for a particular
> hostname need path replacement. i.e. reqrep/resrep.
> e.g. I have a set of 5 servers. While three of them need to be balanced for
> any <hostname>/service1 requests, the other two need to be load balanced for
> <hostname>/service2 requests. How can I dynamically choose between two
> backends depending on hostname+path_beg?
>
> Can I use something like this?
>
> use_backend bk_%[hdr(host),host_to_backend.mapfile]_%[path]
>
> where a request to <hostname>/service1 would mean look for a backend named
> bk_hostname_service1.
> Clearly it will not work like that because <hostname>/service1/login.php will
> break the backend lookup.
Absolutely. And you'd have to have as many backends as possible paths, which
is not practical!
Why don't you run that based on ACLs if you're certain that service2 will
not cause any trouble ?
Eg:
use_backend bk_%[hdr(host),host_to_backend.mapfile]_%[path] if { path_beg
/service2 }
use_backend bk_%[hdr(host),host_to_backend.mapfile]
But again, that requires that you know the exhaustive list of valid paths for
service2. I don't know if that's your case or not, but that could be the
solution.
Regards,
Willy