/ Zope / Apsis / Pound Mailing List / Archive / 2009 / 2009-03 / Using URL matching to distribute to different servers

[ << ] [ >> ]

[ redirecting to https with pound / Sebastiaan van ... ] [ unexpected too many open files / ... ]

Using URL matching to distribute to different servers
Sebastiaan van Erk <sebster(at)sebster.com>
2009-03-09 08:23:06 [ FULL ]
Hi,

I'm trying to use Pound to direct some URLs (site vs user directories) 
to different backend servers.

Basically, this is my configuration:

   Service
     HeadRequire "^Host:\s*(www\.)?sebster\.com"
     URL "/~"
     BackEnd
       Address 192.168.1.10
       Port 80
     End
   End
   Service
     HeadRequire "^Host:\s*(www\.)?sebster\.com"
     URL "/[^~]"
     BackEnd
       Address 192.168.1.11
       Port 80
     End
   End

There are two problems I'm having. First of all, if I read the 
documentation correctly, to stop ~user requests from going to the other 
server when the first server is down, I've got to match the complement 
of the /~ URL in the other service. This is quite annoying with regular 
expressions, and was wondering if there was some other way to go about 
it. Things I can come up with (but do not find in the docs) are:

1) complements
URL ! "/~" (to match the complement of a regex)

2) mutually exclusive services, of which only one can match, something like:

ServiceList
    Exclusive
    Service
      ...
    End
    Service
      ...
    End
End

If you treat ServiceList as a Service itself you could make really fancy 
configurations by nesting.

Maybe there's already some easy way to do this however, if so, I'd love 
to hear it.

The other problem I'm having is that the pattern:

URL "/[^~]"

is not working. It seems to me it should be the complement of the 
pattern "^~" but somehow it isn't... Anybody know what I'm doing wrong here?

Many thanks,
Sebastiaan
Attachments:  
smime.p7s application/x-pkcs7-signature 3328 Bytes

Re: [Pound Mailing List] Using URL matching to distribute to different servers
Dave Steinberg <dave(at)redterror.net>
2009-03-09 16:26:47 [ FULL ]
Sebastiaan van Erk wrote:[...]

Complements would be a nice addition to pound, I agree.  Plus whomever 
sends in the patch to support has a great pun waiting for them.  Who can 
claim this glorious prize?!  :-D

Two options that work with pound right now:

1) Use priorities.  This may not achieve the mutually exclusive 
property, but it may be close enough to basically do what you want.

2) Use an Emergency block.  Then designate the .11 host as the emergency 
host for the first Service block, and vice versa.  That will get you the 
mutually-exclusive part.
[...]

Re: [Pound Mailing List] Using URL matching to distribute to different servers
Sebastiaan van Erk <sebster(at)sebster.com>
2009-03-09 17:04:35 [ FULL ]
Dave Steinberg wrote:[...][...]
[...]

Thinking about it again, I think I was confused this morning. Services 
*are* mutually exclusive, are they not? If there is a service which 
*matches* but has no available backends, you should get an error message 
(service not available), and it shouldn't go to the next service. It 
only keeps trying to find a service as long as it hasn't found a match.

However, complements would still be very useful. :-) And Service nesting 
would be useful for readability and complex cases.

As for the complement of /~ it's not /[^~]... I forgot the empty string 
case... /($|[^~]) should be correct I think, but ! /~ would be so much 
nicer. :)

Regards,
Sebastiaan
Attachments:  
smime.p7s application/x-pkcs7-signature 3328 Bytes

Re: [Pound Mailing List] Using URL matching to distribute to different servers
Juerd Waalboer <juerd(at)convolution.nl>
2009-03-09 17:26:15 [ FULL ]
Sebastiaan van Erk skribis 2009-03-09 17:04 (+0100):[...]

If your pound was compiled with PCRE, you can use the (?!...) construct:

    /^(?!/~)/[...]

Re: [Pound Mailing List] Using URL matching to distribute to different servers
Sebastiaan van Erk <sebster(at)sebster.com>
2009-03-09 18:15:20 [ FULL ]
Juerd Waalboer wrote:[...][...][...]

In fact it is. :-) I didn't know about that construct, and it's exactly 
what I need. Thanks!

Regards,
Sebastiaan
Attachments:  
smime.p7s application/x-pkcs7-signature 3328 Bytes

MailBoxer