PenTesting Company
← Blog

Hide the Nginx Server Header

3 min read

By default, Nginx includes a Server response header that reports the software and version, for example Server: nginx/1.24.0. Version disclosure is a minor issue on its own, but it hands an attacker free reconnaissance, and hiding it is quick.

Turn off the version

Open your Nginx configuration file, usually at /etc/nginx/nginx.conf, and add server_tokens off; inside the http block:

http {
    # ...
    server_tokens off;
    # ...
}

Then check the configuration and reload:

sudo nginx -t
sudo systemctl reload nginx

With server_tokens off;, Nginx still sends Server: nginx but drops the version number.

Removing the name entirely

Hiding the nginx name as well is not possible with a built-in directive. It requires the third-party headers-more module (for example, using more_clear_headers Server;) or a custom build. For most teams, turning off the version is enough hardening.

Have a system you want tested?

Tell us what you are working with and we will follow up with next steps.