Changing the fetch for virtual hosts.

Chris Johnson johnson at nmr.mgh.harvard.edu
Fri Feb 4 15:24:06 CET 2011


> Hi Chris,
>
>>     IF (big IF) I'm reading things right here, it looks like I can
>> rewrite the host name in vcl_recv after the request is received but
>> before the fetch.  If I do this in vcl_recv;
>>
>> if (req.http.host ~ "^old.host.edu") {
>> set req.http.host = "new.host.edu";
>> }
>>
>> will the request go to the new host?
>
> 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?

>
>>  The idea is to stop varnish from basically cache everything twice since
>> both new.host and old.host point to the same set of pages.
>> I don't want varnish doing double duty
>> here.  All varish knows is that the URLs are different and if I
>> understand correctly will treat them as different sets of pages
>> caching both.
>
> You assume correctly. The default is that varnish uses the Host and
> the URL as key, you can check out the vcl_hash subroutine in the
> default VCL.
>
>

      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?  If these examples exist in
the wiki here one would take a guess that it or something very similar
has.  I'd very much like to see an example.  What I'd like to do is
keep what varnish calls the URL and change the host name where the
fetch actually happens. so everything gets fetch from the one virtual
hosst.

-------------------------------------------------------------------------------
Chris Johnson               |Internet: johnson at nmr.mgh.harvard.edu
Systems Administrator       |Web:      http://www.nmr.mgh.harvard.edu/~johnson
NMR Center                  |Voice:    617.726.0949
Mass. General Hospital      |FAX:      617.726.7422
149 (2301) 13th Street      |Survival, all by it self, isn't worth it.
Charlestown, MA., 02129 USA |                 Me
-------------------------------------------------------------------------------


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
http://www.partners.org/complianceline . 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