I'm using Varnish and I'm not quite sure if I should also remove the Server: nginx
HTTP header. Why do someone needs to know that I'm using NGINX? Is it ok to remove this HTTP header from the response or is it needed somewhere? From a security perspective it's probably better to do so?
RFC 7231 says about the Server header:
MAY is interpreted as in RFC 2119:
It is therefore perfectly fine to restrict or remove the Server response header. Of course it's a good idea to be aware of what you might be giving up by doing so. For that, go back to RFC 7231:
Though in practice, attackers don't really check the Server: header. They just try every security exploit they know of, whether your server gives any indication of being vulnerable or not. Removing the Server: header is a security by obscurity action, and an almost entirely ineffective one. But if it makes you feel better, or you're being told to do it by your boss or an auditor, go for it. Just don't expect it to result in any significant improvement to your security posture.
For example,
nmap
can identify a web server with fairly good accuracy even when it's configured to not send aServer
header at all, or when the header content is completely bogus. Try it yourself withnmap -sV -P0 -p 80,443 <IP address>
.The
Server
HTTP header only serves one purpose - identification. It is not required anywhere for running your website properly, and by removing it, nothing is going to break.It reveals the internal server infrastructure, and thus leaks security information that may be useful for potential intrusion.
After gaining knowledge of your web server software, via
Server
HTTP header, the potential intruder can search your web server's publicly known vulnerabilities. Then they can use this information in conjunction with any other information they might gain (e.g. through scanning) - to build a proper attack vector.Thus, you may want to remove the
Server
header altogther, e.g. remove it in nginx.If you have "server_tokens off" in your config (and it seems you do since there's only 'nginx' and not say 'nginx/1.13.11'), then it's OK to leave things as they are now. The problem could appear if you have a vulnerable version, and a bad person could use this info to exploit the vulnerability, but for that your nginx should be publicly accessible. So in a nutshell, use "server_tokens off;" and do no open nginx port for all IPs but for Varnish only, and you should be safe.