Varnish as an HTTP accelator for multiple Zope instances on multiple machines

Dirk Gomez lists at dirkgomez.de
Wed Mar 14 06:40:06 CET 2007


Hi list,

I'm trying to use varnish as an HTTP accelerator for a Zope virtual  
hosting shop. HTTP requests are to be dispatched based on the  
hostname to different Zope backends which reside on different machines.

Varnish runs on Debian testing and my setup doesn't work. The  
vcl.conf is simple and looks correct. (The conciseness of vcl.conf  
was the prime reason to ditch squid btw) This is vcl.conf:

backend default {
         set backend.host = "127.0.0.1";
         set backend.port = "7080";
}


backend thishost {
         set backend.host = "127.0.0.1";
         set backend.port = "7080";
}

backend thathost {
         set backend.host = "192.168.100.199";
         set backend.port = "9080";
}

sub vcl_recv {
         if (req.request == "POST") {
                 pipe;
         }

         # force lookup even when cookies are present
         if (req.request == "GET" && req.http.cookie) {
                 lookup;
         }

              if (req.http.host ~ "^hop.metatest.de") {
                  set req.backend = thishost;
              } elsif (req.http.host ~ "^zop.metatest.de") {
                  set req.backend = thathost;
              } else {
                  error 404 "Unknown virtual host";
              }


}

sub vcl_fetch {
         # force minimum ttl of 180 seconds
         if (obj.ttl < 180s) {
                 set obj.ttl = 180s;
         }
}

/etc/default/varnish hasn't been changed.

varnishlog gives me this output:

    13 RxHeader     c Connection: keep-alive
    13 RxHeader     c Host: zop.metatest.de
    13 VCL_call     c recv
    13 VCL_return   c lookup
    13 VCL_call     c miss
    13 VCL_return   c fetch
    17 BackendClose   default
    17 BackendOpen  b default 127.0.0.1 46677 127.0.0.1 7080

So varnish goes to 127.0.0.1 instead of 192.168.100.199.

Any pointers what is wrong?

Thanks a lot!

-- Dirk





More information about the varnish-misc mailing list