I have three servers in the backend, with a round robin director.

I would like varnish to write a X-Server-By header with the name or ip of the server from which the response was fetched, how can this be done?

link|improve this question
feedback

3 Answers

sub vcl_fetch {
    set obj.http.X-Backend = req.backend;
}

Tested on 2.0.6 in my (non round robin) setup. It should give you something to go on.

link|improve this answer
that just displays the backend id, not the individual server – hoberion Nov 2 '10 at 11:26
feedback

The following is not tested, but might get you started:

sub vcl_deliver {
    set resp.http.X-Served-By = server.hostname;
    deliver;
}
link|improve this answer
that gives you the name of het varnish server – hoberion Nov 2 '10 at 11:35
feedback

You can set the header on your web server eg x-host: server2 and then varnish will return that as part of the response to a cache hit.

I have this working on apache and it works perfectly.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown