URL Matching Plugin
jbj at forbidden.co.uk
jbj at forbidden.co.uk
Fri Sep 1 00:34:22 UTC 2006
For what it's worth, I've written a very simple URL matching plugin
for perlbal at http://jeremy.publication.org.uk/Urlmatch.pm
It's based heavily on Vhosts, since it basically does the same thing
with slightly different criteria, with the intention of being able to
serve directories of static files much quicker than something like
Apache, but still pass through any requests to dynamic content.
A good modification would be to be able to re-write URLs to be
relative to a static root (at the moment, it passes through the whole
URL to the web_server part), but this is ok for us since docroot can be
the same as used by apache.
Imaginary crazy config would be something like (it's a psuedo-apache
matching syntax. * matches non-slashes. ** matches all)...
LOAD urlmatch
CREATE SERVICE static
SET role = web_server
SET docroot = /var/www/
ENABLE static
CREATE POOL apache
POOL apache ADD 127.0.0.1:8000
CREATE SERVICE redir
SET role = reverse_proxy
SET pool = apache
SET persist_backend = on
ENABLE redir
CREATE SERVICE urlmatch
SET listen = 0.0.0.0:80
SET role = selector
SET plugins = urlmatch
SET persist_client = on
URL /**/images/** = static
URL /styles/autostyles.css = redir
URL /styles/* = static
URL /** = redir # This should match everything else
ENABLE urlmatch
...I'm just making this up, but typically you might just have a static
directory you want served directly, and everything else dynamic. Each
URL is checked in turn against those specified for the first available
match.
Comments, Suggestions, Fixes, Complete Re-Writes, Abject Criticism,
Inclusion into perlbal Source Tree etc. all welcome.
Jeremy
More information about the perlbal
mailing list