How to maintain virtualhost name in backend requests correctly
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
> so that in backend, requests made by varnish are logged to the right
> log? In my backend there is 15 namevirtualhosts and now every req
> comes to default apache-log, obviously because the req is not coming
> but a backend IP...
> I tought "set req.http.Host = "dev.foo.fi";" would do the trick but
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).
More information about the varnish-misc