How to maintain virtualhost name in backend requests correctly

Mattias Geniar mattias at nucleus.be
Sun Aug 14 13:32:48 CEST 2011


> How can I tell varnish to do the backend request using the correct
virtual host 
> so that in backend, requests made by varnish are logged to the right
virtual host 
> log? In my backend there is 15 namevirtualhosts and now every req
varnish makes 
> comes to default apache-log, obviously because the req is not coming
using name 
> but a backend IP...
> 
> I tought "set req.http.Host = "dev.foo.fi";" would do the trick but
not...

This doesn't make sense. Varnish will keep the original host-header
intact, so your backend should see the request coming correctly. It may
be that your Virtual Host is bound on the wrong IP and thus loading its
configuration from the wrong virtual host?

To debug, place a simple PHP script in (one of) your virtual host(s)
that simply does this:
<?php print_r($_SERVER); ?>

That will tell you the host name, server port, ... that your backend
actually gets to see (assuming PHP is enabled on your system).

Regards,
Mattias




More information about the varnish-misc mailing list