server.ip for "undoing" namevirtualhosts issues

Chris Hecker checker at
Mon Jul 12 08:02:15 CEST 2010

I'm running the configuration #1 I mentioned here:

Basically, varnishd listening on a bunch of ips, and then httpd 
listening on localhost:80 and all the sites as NameVirtualHosts.  This 
seems to work well so far, but it has the disadvantage that if somebody 
goes to the raw ip addresses with their browser, they'll get the same site.

Can I use server.ip in vcl_recv to force the host to the right site if 
there's no host record?  What would the code look like to do this? 
Something like:

if(! {
	if(server.ip == "a.b.c.d") {
		set = "";
	} elsif(server.ip == "a.b.c.e") {

Would that work?  Has anybody tried that?


More information about the varnish-misc mailing list