Varnish Change Web Server Signature Headers

in Categories last updated July 8, 2010

I‘m using Varnish cache infront of Apache web server and I’d like change my web server signature from

Apache/2.2.8 (Ubuntu) mod_python/3.3.1 Python/2.5.2 mod_ssl/2.2.8 OpenSSL/0.9.8g

To:

Apache Web server

How do I change headers using Varnish?

You can simply use the following configuration (edit Varnish config file) and append the following configuration:

unset beresp.http.Server;
set beresp.http.Server = "Apache Web Server";

Save and close the file. Restart Varnish:
# /etc/init.d/varnish restart
OR
# /etc/init.d/varnish reload

How Do I Test New Headers?

Simply use curl command as follows:
$ curl -I http://www.example.com/
$ curl -I http://www.cyberciti.biz/

Sample outputs:

HTTP/1.1 200 OK
Server: Apache Web Server
Content-Type: text/html; charset=utf-8
Status: 200 OK
P3P: CP="NOI DSP COR NID ADMa OPTa OUR NOR"
X-UA-Compatible: IE=7
ntCoent-Length: 163218
X-Varnish: 3079018010 3079016087
Expires: Thu, 08 Jul 2010 16:21:52 GMT
Cache-Control: max-age=0, no-cache, no-store
Pragma: no-cache
Date: Thu, 08 Jul 2010 16:21:52 GMT
Connection: keep-alive

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.

Share this on (or read 1 comments/add one below):

1 comment

  1. I put the code on /etc/varnish/default.vcl on my centos box but varnish failed to start

    Have a question? Post it on our forum!