Changing the fetch for virtual hosts.

Chris Johnson johnson at
Mon Feb 7 14:49:26 CET 2011

      Huh.  Well, I think I've done everything everyone said was right.
Here's a snippet of what I have in varnish's default.vcl;

backend freesurfer {
       .host = "";
       .port = "8080";

which happens to be the same place the default backend points to
because this is a different virtual host on the same server.

And in vcl_recv I have;

     if ( ~ "^") {
       set = "";
       set req.backend = freesurfer;

which referenes my backend declaration and rewrites the header host

      How do I tell if this is working?  Remember, I'm trying to make
the old virtual host references to be keyed
on and fetch from the new virtual host so varnish
doesn't cache everything twice.

      Varnich didn't complain when I restarted it and seems to be
caching.  I'm just not sure what at this point.

> On Fri, Feb 4, 2011 at 5:17 PM, Chris Johnson
> <johnson at> wrote:
>> On Fri, 4 Feb 2011, Per Buer wrote:
>>>      if ( ~ "^") {
>>>        set req.backend = foo;
>>>      }
>>     Which goes in vcl_recv and in his case foo is a backend declaration
>> function that sets up .host and .port for the virtual host I want, yes?
> Almost. foo is here a declared backend - declared with the keyword
> "backend" -
> -- 
> Per Buer, Varnish Software
> Phone: +47 21 98 92 61 / Mobile: +47 958 39 117 / Skype: per.buer
> Varnish makes websites fly!
> Want to learn more about Varnish?

Chris Johnson               |Internet: johnson at
Systems Administrator       |Web:
NMR Center                  |Voice:    617.726.0949
Mass. General Hospital      |FAX:      617.726.7422
149 (2301) 13th Street      |Man's a kind of missing link
Charlestown, MA., 02129 USA |fondly thinking he can think.  Piet Hein

The information in this e-mail is intended only for the person to whom it is
addressed. If you believe this e-mail was sent to you in error and the e-mail
contains patient information, please contact the Partners Compliance HelpLine at . If the e-mail was sent to you in error
but does not contain patient information, please contact the sender and properly
dispose of the e-mail.

More information about the varnish-misc mailing list