Varnish Change Web Server Signature Headers

by on July 8, 2009 · 1 comment· LAST UPDATED July 8, 2010

in

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
TwitterFacebookGoogle+PDF versionFound an error/typo on this page? Help us!

{ 1 comment… read it below or add one }

1 khupcom June 3, 2013 at 4:48 am

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

Reply

Leave a Comment

Tagged as: , , , , , , , , , , , , , , ,

Previous Faq:

Next Faq: