Using a Selector

Jeremy James jbj at forbidden.co.uk
Tue Dec 11 17:56:58 UTC 2007


J Davis wrote:
> I'm trying to configure both a reverse_proxy service and a web server
> service on the same perlbal instance.
> I want to use URL matching to determine which URL's get served by the
> reverse_proxy and which get served by the web_server.
> By looking at the documentation and some example configurations I can
> see that this type of setup probably involves creating a selector
> service and by digging through the mail archives I found a link to a "
> Urlmatch.pm <http://Urlmatch.pm>" plugin but I can't find any
> documentation on how to configure perlbal to tie all of this together.

Urlmatch (as hosted on jeremy.publication.org.uk) is largely deprecated
by the official Vpath(s) plugin included in 1.60 - I believe it offers
the same functionality (although uses a straightforward regexp matching
instead of my slightly funky apache-style url matching).

> Below is a partial example of how I think this might work but I don't
> have any idea how to tell urlmatch how to work.
> Any pointers or examples would be greatly appreciated.

> ...snip...

You shouldn't normally need to specify a listen address for each
service, unless that's behaviour you explicitly want...

I'd imagine something like (not tested!):

-- start of perlbal.conf --

LOAD vpath

# Or move these into a seperate nodelist file
CREATE POOL apache_backends
  POOL apache_backends ADD 192.168.1.40
  POOL apache_backends ADD 192.168.1.41
  POOL apache_backends ADD 192.168.1.42

CREATE SERVICE apache_proxy
  SET role            = reverse_proxy
  SET pool            = apache_backend
  SET persist_backend = on
  SET verify_backend  = on
ENABLED apache_proxy

CREATE SERVICE local_images
  SET role            = web_server
  SET docroot         = /var/imageroot/
  SET dirindexing     = 0
ENABLE local_images

CREATE SERVICE mainselector
  SET listen          = 0.0.0.0:80
  SET role            = selector
  SET plugins         = vhost

  VPATH /images/.*    = local_images
  VPATH .*            = apache_proxy
ENABLE mainselector

-- end of perlbal.conf --

Note that images would be served from the docroot, ie. you are accessing
files under a directory at /var/imageroot/images/ - perhaps a update to
vpath will allow chopping prefixes off URLs? (hint hint)

Also, note that you can't officially have multiple selectors chained
together (ie. a vhost selector going on to a vpath selector). However, I
have a posted a patch to this list that allows you to do this (dated
25th April '07 with the title 'Patches: Chained Selectors and Multiple
Listen'). We have been using this on a medium-loaded server since
posting that without issues.

Best wishes,
Jeremy



More information about the perlbal mailing list