Removing server name and version

By default, NGINX will set a Server response header, which will contain the product name and version number. While it's mostly a minor thing, some see this as a leakage of information which gives hackers a potential starting point to look for attack vectors. We can remove this version number to remove the version data from the header. Here's how to do it:

server { 
    listen 80; 
    server_name headermod.nginxcookbook.com; 
    server_tokens off; 
} 

The server_tokens directive is set to on by default, so we set it to off in order to disable the version number. This also removes the version number from the error pages (such as the 404 error page) as well.

If you need to completely remove the server header, you'll either need a third-party module or the Plus (paid) edition of NGINX, which allows you to override it.