multiple domains -> varnish -> one backend

Jon Drukman jsd at cluttered.com
Thu May 1 19:27:01 CEST 2008


I am using varnish to accelerate several different incoming domains. 
They all hit the same backend server, but the server responds 
differently depending on the host header (which I passing in as 
X-Orig-Host).

Varnish however is ignoring the incoming domain name and just using the 
path as the cache key.  Example:

http://domain1.com/page1
http://domain2.com/page1

The backend server responds differently but varnish serves whichever one 
was requested first.  How do I tell varnish that host+path is 
significant instead of just path?

my vcl_recv looks like this:

sub vcl_recv {
     set req.url = regsub(req.url, "^", "/site");
     set req.http.X-Orig-Host = req.http.host;
     set req.http.host = "originserver.com";

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

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

-jsd-




More information about the varnish-misc mailing list