server.ip for "undoing" namevirtualhosts issues

Chris Hecker checker at d6.com
Mon Jul 12 10:45:59 CEST 2010


Okay, I'm trying this and it works.  I realized I don't have any 
NameVirtualHost sites going through varnish right now, so I just stomp 
the req.http.Host with the correct site name at the top, and that let me 
remove all the www. stripping from the vcl_recv.  I did notice that 
Host: is set by browsers even on numerical ips (due to HTTP/1.1 I 
guess), so I think the right if is something like:

if(!req.http.host ||
    (req.http.host ~ "^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$"))
{
	blah;
}

but I haven't tried that yet, since I realized I don't need it yet. 
Does that look right?

Chris


On 2010/07/12 00:46, Poul-Henning Kamp wrote:
> In message<4C3AAFE7.3010306 at d6.com>, Chris Hecker writes:
>
>> 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(!req.http.host) {
>> 	if(server.ip == "a.b.c.d") {
>> 		set req.http.host = "a.com";
>> 	} elsif(server.ip == "a.b.c.e") {
>> ...etc
>
> Yes, that is server.ip was intended to be used.
>
> If that does not work, it is a bug.
>



More information about the varnish-misc mailing list