Varnish Change Web Server Signature Headers

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

ADVERTISEMENTS

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
🐧 If you liked this page, please support my work on Patreon or with a donation.
🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source/DevOps topics:
CategoryList of Unix and Linux commands
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04

ADVERTISEMENTS
1 comment… add one
  • khupcom Jun 3, 2013 @ 4:48

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

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.