varnish backend redirection based on url

Shibashish shib4u at gmail.com
Thu Aug 4 11:48:53 CEST 2011


On Wed, Aug 3, 2011 at 11:28 PM, Sandro guly Zaccarini <guly at luv.guly.org>wrote:

> On Wed, Aug 03, 2011 at 09:59:54PM +0530, Shibashish wrote:
> > This doesn't work...
> >
> >   if (req.http.host == "www.domain.com" && req.url  ~ "^/hi$") {
> >        set req.backend = hiserver; }
> >    elseif (req.http.host == "www.domain.com" && req.url  ~ "^/$") {
> >         # if /hi is not specified, i.e go to /
> >        set req.backend = enserver; }
> >    else  {set req.backend = default; }
> #
> > all other sites go here
>
>
> look: you are checking for /hi / everythingelse
> if uri is /hi/ it doesn't match anything so it fallback to last else
>
> not sure if you want to match /hi or /hi/..but i think that could be
> part of the issue.
>
> sz
> --
>  /"\   taste your favourite IT consultant
>  \ /   gpg public key http://www.guly.org/guly.asc
>   X
>  / \
>
> Good pointers... finally got this to work...

   if (req.http.host ~ "www.domain.com" && !req.url  ~ "^/hi/|^/hi") {
       set req.backend = enserver; }
  elseif (req.http.host ~ "www.domain.com" && req.url  ~ "^/hi/|^/hi") {
       set req.backend = hiserver; }
   else  {set req.backend = default;}

Thanks a ton.

ShiB.
while ( ! ( succeed = try() ) );
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20110804/b9fb8c3a/attachment-0003.html>


More information about the varnish-misc mailing list