How to hide the nginx version

Removing the version number from HTTP headers and error pages.

One negative consequence of hiding the version number is that it's harder for those who collect data on which web server version that is the most popular. If you don't care about that, there's no need to advertise the version number to hackers.

The version number of your nginx installation is always sent in the HTTP response header Server and displayed at the bottom of all default error pages.

HTTP/1.1 200 OK
Server: nginx/1.4.1

If you want to hide the version number, set the server_tokens option in the http context to off in /etc/nginx/nginx.conf.

server_tokens off;

For the changes to take effect, you must restart nginx.

sudo service nginx restart

Note: Where the file is located and how to restart nginx may vary depending on operating system.