title: Varnish as a cache in front of apache virtual hosts
body: <p>I would like to configure varnish as a cache for one of my websites for a temporary heavy load.</p>
  
  <p>I set up several virtual machines with varnish that should cache my main website.
  As my main server hosts several websites the apache server is configured to be a virtual host server.</p>
  
  <p>So I defined the main website domainname in the default.vcl instead of an IP address, hoping varnish would propagate the requests properly to the right apache virtualhost.
  But it seems it just uses the IP address, and is caching the apache default page that appears when sending a http request to my main website ip address.</p>
  
  <p>Is there a way to configure varnish so it calls my backend using the right url, and not an IP:port ?</p>
  
  <p>my varnish config looks like :</p>
  
  <pre><code>backend default{
    .host = "www.myvhost.com";   
    .port = "80"; 
  }
  </code></pre>
  
  <p>instead of :</p>
  
  <pre><code>backend default{
    .host = "my.ip";   
    .port = "80"; 
  }
  </code></pre>
  
  <p>because I need  the varnish instances : <a href="http://www1.myvhost.com" rel="nofollow">http://www1.myvhost.com</a>, <a href="http://www2.myvhost.com" rel="nofollow">http://www2.myvhost.com</a> ... to cache the main server <a href="http://www.myvhost.com" rel="nofollow">http://www.myvhost.com</a>
  but not <a href="http://myip:80/" rel="nofollow">http://myip:80/</a></p>
  
  <p>Thanks for your help</p>