How to direct traffic based on URL

Brad Fitzpatrick brad at danga.com
Tue Sep 13 10:54:25 PDT 2005


Well, the $host variable doesn't contain the URI request path, so it won't
match the "/rss" in your VHOST directive.

Here, use this:

   http://danga.com/temp/DeliciousSelector.pm

Then load the plugin "DeliciousSelector" and remove your "VHOST" config
lines.  I've hardcoded "delicious_rss" and "delicious" for your pool
names.

- Brad



On Tue, 13 Sep 2005, max michaels wrote:

> Thanks for hints, but I'm still having problems getting adjustments
> to vhost.pm to work. Here's what I've change unsuccessfully:
>
> diff Perlbal-1.37.changes/lib/Perlbal/Plugin/Vhosts.pm
> Perlbal-1.37/lib/Perlbal/Plugin/Vhosts.pm
> 37c37
> <             unless $host =~ /^[\/\w\-\_\.\*]+$/;
> ---
>  >             unless $host =~ /^[\w\-\_\.\*]+$/;
>
> and here is my perlbal.conf:
>
> load Vhosts
>
> CREATE POOL delicious_rss
>          POOL delicious_rss ADD x.x.x.x:80
>
> CREATE POOL delicious
>          POOL delicious ADD y.y.y.y:80
>
> CREATE SERVICE balancer2
>    SET listen          = 69.9.36.75:80
>    SET role            = selector
>    SET plugins         = vhosts
>    VHOST del.icio.us/rss = delicious_rss
>    VHOST del.icio.us = delicious
> ENABLE balancer2
>
>
> # always good to keep an internal management port open:
> CREATE SERVICE mgmt
>    SET role   = management
>    SET listen = 127.0.0.1:60000
> ENABLE mgmt
>
> It still seems to randomly choose and not differentiate. Any Ideas?
>
> Thanks!
>
> -max
>
> On Sep 12, 2005, at 1:17 PM, Brad Fitzpatrick wrote:
>
> > You'll have to write a service selector plug-in, which isn't as
> > scary as
> > it sounds.  Look at the Vhosts.pm plugin for virtual hosts (which
> > redirects to a different pool based on hostname), and change it to
> > work on
> > the URLs that you want.
> >
> > - Brad
> >
> >
> > On Mon, 12 Sep 2005, Max Michaels wrote:
> >
> >
> >> Howdy,
> >>
> >> I was just wondering if there is a good guide out there on how to
> >> redirect based upon what the URL is. For example, I want to direct
> >> any
> >> traffic that has /rss at the end of it to backend_server b and
> >> everything else to backend_server a. Thanks!
> >>
> >> -max
> >>
> >>
> >
>
>


More information about the perlbal mailing list