Multiple virtual host with different IP's

Robert Socha socha at socha.it
Mon Sep 24 18:04:29 CEST 2012


Hi


W dniu 2012-09-24 16:11, dhanushka ranasinghe pisze:
> Hi  guys ,
> With follwing configuration   varnish only cache the content of the
> *content.org <http://content.org> * , its not caching the *content.com
> <http://content.com>* , Do i need to define multiple back-ends for each
> virtual-hosts, can any one giude me how to do that .Or do i need to
> configure  separate Varnish instance for each VHOST.
> 

You need define multiple backends. No need for separate instances.




> server {
>     listen      10.100.1.1:8080 <http://10.100.1.1:8080>;
>     server_name   content.com <http://content.com>;
...

backend bkcontentcom {
     .host = "10.100.1.1";
     .port = "8080";
}


>  server {
>                 listen      10.100.1.2:8080 <http://10.100.1.2:8080>
>                 server_name  cache.org <http://cache.org>;
...

backend bkcacheorg {
     .host = "10.100.1.2";
     .port = "8080";
}

And in the begining of vcl_recv()

if (req.http.host ~ "^(www\.)?content\.com$") {
	set req.backend = bkcontentcom;
} else {
	// for cache.org
	set req.backend = bkcacheorg;
}



And of course your backends need to provide correct Cache-Control
headers (ie. max-age or s-max-age).

Greetings
-- 
Robert Socha





More information about the varnish-misc mailing list