In the realm of web server security and configuration, few directives are as simple yet impactful as server_tokens. Commonly found in popular web servers like Nginx and Apache, this configuration setting plays a pivotal role in controlling the information a server reveals about itself through HTTP headers.
When a client—typically a web browser or automated scanner—makes a request to a server, the server’s response often includes a Server header. This header can reveal detailed version information about the web server software and, sometimes, its underlying technologies. While this may seem harmless, disclosing such information can expose the server to security risks. That’s where server_tokens comes into play.
What Does server_tokens Do?
The server_tokens directive determines what kind of version and server information is included in HTTP response headers. By default, many web servers include complete information, such as:
Server: nginx/1.21.3
With server_tokens, administrators can configure the server to return minimal or no version details. For example:
Server: nginx
This subtle change can be a valuable addition to a server hardening strategy.

Configuration Options in Nginx
In Nginx, the server_tokens directive is placed within the http
, server
, or location
contexts of the configuration file. Below are the common options:
- on — This is the default and includes the full version number in the Server header field.
- off — This disables the inclusion of the version number, showing only the software name.
To disable version disclosure completely in Nginx, insert the following line into your configuration:
server_tokens off;
Once the configuration is updated, reload or restart the Nginx service for the changes to take effect.
Apache’s Equivalent Setting
For Apache users, the equivalent directive is a combination of:
ServerTokens Prod ServerSignature Off
These settings limit the server’s response to output something like:
Server: Apache
Instead of:
Server: Apache/2.4.51 (Unix) OpenSSL/1.1.1
Like Nginx, this small change helps reduce the attack surface of your web server by minimizing publicly exposed information.
Why Is This Important?
The main reason to obscure server version information is to enhance security. When attackers scan for vulnerable servers, they often look for specific versions with known exploits. By eliminating clues such as server type and version, you make it more difficult for attackers to tailor their attacks.
Here are some advantages of using the server_tokens directive:
- Defense by Obscurity: While not a primary defense mechanism, reducing informational output can frustrate automated attack scripts.
- Simplified Compliance: Certain security standards recommend minimizing unnecessary data leaks, which server_tokens helps to enforce.
- Cleaner User Experience: Concealing server details can lead to more professional and neutral-looking error messages or headers.

Potential Limitations
It is worth noting that simply turning off server_tokens is not a panacea for server security. Determined attackers can still use various fingerprinting techniques to deduce the server type or even the operating system.
Some limitations include:
- Indirect Fingerprinting: Features like default error pages or unique server behaviors can still give away information.
- Not a Replacement for Updates: Always keep software up to date; hiding versions doesn’t eliminate vulnerabilities.
- User-Agent Responses: Sometimes, embedded resources or third-party modules may still leak version data independently.
Best Practices
To secure your server environment effectively:
- Use server_tokens off or its equivalent in your server configuration.
- Regularly update server software and monitor vulnerability bulletins.
- Employ intrusion detection systems and thorough logging mechanisms.
- Combine security mechanisms such as firewalls, rate-limiting, and TLS encryption.
Conclusion
In conclusion, server_tokens is a straightforward yet crucial configuration directive that can elevate your server’s security posture. By minimizing the amount of technical information exposed to the public, you reduce potential vectors for exploitation. Although it’s not a comprehensive solution in itself, it represents a key step in a multi-faceted approach to server hardening.
For any organization serious about cybersecurity, configuring server_tokens properly should be part of the foundational server setup process. Whether you’re running a single site or managing a large-scale infrastructure, attention to such details reflects a mature and responsible approach to digital security.