Using Varnish to Proxy 1000s of different sites

Adrian Lienhard adi at netstyle.ch
Thu Aug 5 22:19:59 CEST 2010


Hi Tony,

I've a setup with Varnish for a couple hundred domains as follows:

Client -> Varnish -> Apache -> Backend 1, ... Backend n

Varnish has Apache as a single backend. Apache serves as a reverse proxy to rely requests to the respective backend instance based on the domain name. That is, the selection of the backend does not happen in Varnish but in Apache using RewriteMap and RewriteRule. Works very well, although, we haven't rolled it out yet.

Cheers,
Adrian

___________________
http://www.adrian-lienhard.ch/

On Aug 5, 2010, at 18:21 , Tony Primerano wrote:

> On Thu, Aug 5, 2010 at 10:50 AM, Per Buer <perbu at varnish-software.com>wrote:
> 
>> On Thu, Aug 5, 2010 at 4:33 PM, Tony Primerano <tony.primerano at gmail.com>
>> wrote:
>>> (..)
>>> But what if I have 1000s of backends and I choose them based on the
>> domain
>>> that user's hit varnish with.   Is this something Varnish handles or is
>> it
>>> only intended to work with a handful of backends?
>> 
>> It's not built for that.  Kristians dns director might help you out a
>> bit, but it just entered trunk (will be in 2.1.4).
>> 
> 
> http://kristianlyng.wordpress.com/2010/08/02/varnish-backend-selection-through-dns/
> 
> Looks promising but in the end I think I end up with the same amount of
> code. (a vcl_fetch with 1000s of ifs)
> 
> Some clarification on what I am trying to do..  without code samples ;-)
> 
> All traffic to foo.com should go to bar.com (update Host header and open
> connection to bar.com)
> All traffic to some.food.com should go to meal.com (update Host header and
> open connection to meal.com)
> 
> repeat for 1000 domains and or subdomains.
> 
> I'm just allowing bar.com content to show on foo.com without modifying
> foo.com's virtual host configurations.
> 
> 
> 
>>> Also, it would be really cool if I could do something like this..
>>> sub vcl_recv {
>>>  set req.http.host = "example.com";
>>>  set req.backend.host  = req.http.host;
>>>  return(pass);
>>> }
>> 
>> That would be an open proxy. Spammers bonanza. Please don't do that. :-)
>> 
>> If you still want to do it you could have a look at
>> 
>> http://ingvar.blog.linpro.no/2010/05/26/accelerating-the-internet-or-actually-squid-with-varnish/
>> 
>> and use a non-caching proxy in stead of squid. That would work.
>> 
>> 
>> 
>> --
>> Per Buer,  Varnish Software
>> Phone: +47 21 98 92 61 / Mobile: +47 958 39 117 / skype: per.buer
>> 
> _______________________________________________
> varnish-misc mailing list
> varnish-misc at varnish-cache.org
> http://lists.varnish-cache.org/mailman/listinfo/varnish-misc









More information about the varnish-misc mailing list