selecting reproxy pool to use based on request_uri

Robby Dermody robbyd at
Sat Oct 6 23:51:39 UTC 2007

No doubt. I've love to have it. Thanks!


-----Original Message-----
From: Jonty [mailto:jonty.wareing at] 
Sent: Saturday, October 06, 2007 4:20 PM
To: Robby Dermody
Cc: perlbal at
Subject: Re: selecting reproxy pool to use based on request_uri

Hey Robby,

I wrote a plugin that does exactly this (along with allowing you to
select a pool based on other rules, such as IP/Cookies/Etc) - I could
make it available if you wish?

Jonty Wareing

On 10/5/07, Robby Dermody <robbyd at> wrote:
> Hey guys,
> I have a perlbal plugin that hooks into 'start_proxy_request' in order to
> slap on some extra http headers for incoming requests. I'd like to enhance
> this plugin to reproxy an incoming request to one of two pools depending
> the request made. This is because I have a server A handling requests to
> /foo and /bar (e.g. a pool of one server), and a server B, C and D
> requests to everything else (e.g. a different pool of 3 servers). I'd like
> to just use port 80 and forward to one or the other as needed. Thus I
> avoid having to use both 80 and some other, non-standard port and having
> people behind restrictive firewalls not be able to access the service
> possibly.
> The skeleton of new code would probably look like what I have below, but I
> am totally lost with how to have perbal use a different backend than the
> specified in the active this possible? Can I do it in
> start_proxy_request, or does it have to be another hook? Any code or
> pointers that could be provided would help out (I'm not a perl developer,
> obviously :).
> [.]
> $svc->register_hook('CastdotGlue', 'start_proxy_request', sub {
> my Perlbal::ClientProxy $cliproxy = shift;
> my Perlbal::HTTPHeaders $hds = $cliproxy->{req_headers};
>        my Perlbal::Service $svc = $cliproxy->{service};
> return 0 unless defined $hds && defined $svc;
> return 0 unless $hds->request_uri;
> if($hds->request_uri =~ m/^\/foo.*/i || $hds->request_uri =~ m/^\/bar.*/i)
> {
>         //reproxy to an entry in the first pool
> }
> else
> {
>         //reproxy to an entry in the second pool
> }
> [.]
>     # existing functionality that slaps on the headers is here, etc.
> }
> [.]

More information about the perlbal mailing list