Changing the fetch for virtual hosts.

Per Buer perbu at varnish-software.com
Fri Feb 4 16:04:26 CET 2011


On Fri, Feb 4, 2011 at 3:24 PM, Chris Johnson
<johnson at nmr.mgh.harvard.edu> wrote:
>>
>> Not unless you explicitly set the backend later. The only thing you do
>> here is to set a new Host: header, which makes sense, btw.
>
>     Not clear on what you mean by that first sentence.  Can you
> elaborate?

Sure. You need to set what backend your using something like this at some point:

       if (req.http.host ~ "^www.example.com") {
         set req.backend = foo;
       }

If you already have set req.http.host before reaching this things will be fine.

>     I was looking through the example snippets to see if there was
> anything to prevent redundant caching.  I've found two exampes that
> look interesting.  They are
>
>     o  Redirecting the browser to another hostname
>
>     o  Using static regular expressions to munge an incoming HTTP
>        request to become something very different. Very useful if
>        you want to apply the same varnish config to all sites on
>        a server hosting many, many small sites
>
>     The last sounds closer to what I'm trying to do to prevent
> redundant caching.
>
>     Has anyone had/solved this problem?

I think your approach is fine.


-- 
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? http://www.varnish-software.com/whitepapers




More information about the varnish-misc mailing list