selecting reproxy pool to use based on request_uri

Jonty jonty.wareing at gmail.com
Sun Oct 7 14:07:14 UTC 2007


Right, I'll try to make it available early this week when I'm back in
the office.

Jonty Wareing
--
Developer
Last.fm

On 10/7/07, Robby Dermody <robbyd at u20.org> wrote:
> No doubt. I've love to have it. Thanks!
>
> Robby
>
> -----Original Message-----
> From: Jonty [mailto:jonty.wareing at gmail.com]
> Sent: Saturday, October 06, 2007 4:20 PM
> To: Robby Dermody
> Cc: perlbal at lists.danga.com
> 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
> --
> Developer
> Last.fm
>
> On 10/5/07, Robby Dermody <robbyd at u20.org> 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
> on
> > 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
> handling
> > 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
> would
> > 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
> one
> > specified in the active service.is 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 :).
> >
> > myplugin.pm:
> > [.]
> >
> > $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