I have a centos 5.x server running Apache+Drupal with 13 vhosts. These vhosts are all Top Level Domains. Munin reports heavy swapping for a few days in a month and I discovered that these are mostly anonymous users. So I thought of having varnish handle the anonymous traffic. I searched the web and found no literature on configuring VCl file file for VHOSTS. Would appreciate if someone could point me to a source.
1 Answer
Varnish doesn't need to be vhost aware, whist it operates on layer 7 - it can just listen on an IP(s) and pass to the respective backend (Apache) to decide which virtualhost it needs to serve.
In terms of being able to differentiate configurations - you can use use http.host
-
Eg.
sub vcl_recv {
# Don't cache www.example.com
if (req.http.host ~ "^(www\.example\.com)$") {
return(pass);
}
Otherwise, if you don't need virtualhost specific configuration - you don't need to even let Varnish know.