varnish forward to wrong backend

Lei Wang leiwang at rhapsody.com
Fri Aug 16 00:11:09 CEST 2013


Hi James,

It is very simple like below:
sub vcl_recv {
  if (req.url ~ "^/my-home") {
    set req.http.host = "www.mydns1.com";
    set req.backend = backend1 ;
  } elsif (req.http.host ~ "^www.mydns2.com") {
    set req.http.host = "www.mydns2.com";
    set req.backend = backend2
  } elsif (req.http.host ~ "^www.mydns3.com") {
    unset req.http.Accept;
    set req.backend = backend3;
  } elsif (req.http.host ~ "^www.mydns4.com") {
    unset req.http.Accept;
    set req.backend = backend4;
  } else {
    error 404 "Unknown virtual host";
  }
}


Thanks,

Lei


On Thu, Aug 15, 2013 at 2:12 PM, James Pearson <james at ifixit.com> wrote:

> Excerpts from Lei Wang's message of 2013-08-15 11:09:13 -0700:
> > I have varnish 3 (varnish-3.0.4 revision 9f83e8f) installed to cache
> > multi-site in one configuration. Sometimes Varnish switched to use the
> > first backend in the configuration for all the requests to the other
> sites.
> > As in the sample configuration below, the request to backend2, backend3,
> > backend4 sometimes forwarded to backend1. Does anyone have the same
> problem
> > or know any solution, suggestion?
> >
> > The varnish backend configuration is quite simple like below:
> >
> > [snip]
>
> What does the rest of your config look like, specifically the part that
> assigns
> a backend?
>  - P
>
> _______________________________________________
> varnish-misc mailing list
> varnish-misc at varnish-cache.org
> https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20130815/2080eea0/attachment.html>


More information about the varnish-misc mailing list