How to Hide Your Server Version in HTTP Headers

Your web server, language and framework announce their exact versions in every response unless you tell them not to. This guide shows how to find those leaks and remove them on every major platform.

Covers
Server Header, X-Powered-By, Information Disclosure

Out of the box, most web stacks tell every visitor exactly what they run: Server: Apache/2.4.41 (Ubuntu), X-Powered-By: PHP/7.4.3, X-AspNet-Version: 4.0.30319. These headers have no function for visitors, but they give an attacker a ready-made shopping list: look up the version, find the published vulnerabilities, try the exploits. This guide shows how to find these leaks and switch them off on every major platform.

Step 1: See What Your Site Discloses

Start by finding out what you are leaking. Run your site through the ShowDNS Server Signature Test. It checks the response headers and a default error page. It flags exact versions, end-of-life software, debug headers, internal hostnames and framework fingerprints, and tells you how to fix each one.

Or check by hand with curl:

bash
# Response headers of the home page curl -sI https://example.com | grep -iE '^(server|x-powered-by|x-aspnet|x-generator|via):' # A page that does not exist: default error pages often print the version curl -s https://example.com/this-page-does-not-exist | grep -ioE '(apache|nginx|iis|php|openssl)[/ ][0-9.]+'

Headers that commonly leak versions

HeaderExampleSent by
Servernginx/1.18.0, Apache/2.4.41 (Ubuntu) OpenSSL/1.1.1fThe web server
X-Powered-ByPHP/7.4.3, Express, ASP.NET, Next.jsLanguage runtime or framework
X-AspNet-Version4.0.30319ASP.NET (.NET Framework)
X-AspNetMvc-Version5.2ASP.NET MVC
X-GeneratorDrupal 10 (https://www.drupal.org)CMS
Via1.1 varnish (Varnish/6.0)Caches and proxies
Hiding is not patchingRemoving version numbers stops casual scanners from matching you against a vulnerability list in one request. It does not fix anything. If the test shows end-of-life software (for example PHP 8.1 or older, or OpenSSL 1.1.1), upgrade first. Then hide the version.

Step 2: Hide the Web Server Version

The Server header comes from whatever answers the request first: your web server, or your CDN if you use one. The setting below also removes the version from the server's default error pages.

Nginx

Add server_tokens off; to the http block so it applies to every site:

nginx
# /etc/nginx/nginx.conf http { server_tokens off; # no version in headers or error pages # ... rest of config }
bash
sudo nginx -t && sudo systemctl reload nginx

Stock nginx always sends Server: nginx. To remove the header completely, install the headers-more module (libnginx-mod-http-headers-more-filter on Debian and Ubuntu) and add:

nginx
more_clear_headers Server;

Step 3: Remove X-Powered-By and Framework Headers

X-Powered-By is added by the language or framework, not the web server, so fix it where it is created. Removing it there also covers every server and proxy in front.

PHP

In php.ini (find it with php --ini, and edit the PHP-FPM copy too if you use it):

Command
expose_php = Off
bash
sudo systemctl restart php8.3-fpm # match your PHP version, or restart Apache for mod_php

This setting cannot be changed with ini_set() at runtime. If you cannot edit php.ini, strip the header at the web server instead (see the Nginx and Apache tabs).

Using a CDN?Cloudflare, Fastly and most other CDNs replace your origin's Server header with their own, but they pass X-Powered-By and other origin headers straight through. In Cloudflare, remove them under Rules → Transform Rules → Modify Response Header, using the Remove operation. Fixing the origin is still better: anyone who finds your origin IP can bypass the CDN.

Step 4: Check Error Pages and Other Leaks

Headers are not the only place versions appear. Check these too:

  • Default error pages. ServerSignature Off (Apache), server_tokens off (nginx) and showServerInfo="false" (Tomcat) cover the built-in pages. A custom 404 and 500 page is even better.
  • Debug mode. Django's DEBUG = True, Laravel's APP_DEBUG=true, the Symfony profiler (X-Debug-Token header) and ASP.NET detailed errors can expose source code, file paths and secrets. They must be off in production. This is far more serious than a version number.
  • Internal hostnames and IPs. Headers such as X-Backend-Server or a Via header that names your internal machines map your network for an attacker. Remove them at the load balancer.
  • CMS generator tags. <meta name="generator"> and X-Generator headers.

Step 5: Verify the Fix

Repeat the checks from step 1. Every header that leaked a version should now be gone or show no version:

bash
curl -sI https://example.com | grep -iE '^(server|x-powered-by|x-aspnet)' # Expected: "server: nginx" (or nothing), and no x-powered-by / x-aspnet-version curl -s https://example.com/this-page-does-not-exist | grep -ioE '(apache|nginx|php)[/ ][0-9.]+' # Expected: no output

Then confirm with the ShowDNS tools, which all apply the same checks:

1. Does hiding the server version make my site secure?

No. It removes free reconnaissance, so automated scanners cannot match your exact version to a list of known vulnerabilities in one request. The software is just as vulnerable as before. Patching is the real fix; hiding the version is a small, cheap layer on top.

2. Is "Server: nginx" or "Server: Apache" without a version a problem?

Not really. A product name alone tells an attacker very little, and it is easy to guess from other clues anyway. Removing the version is what matters. Removing the header completely is optional and usually needs an extra module.

3. My Server header says Apache/2.4.41 (Ubuntu). Ubuntu backports security fixes, so is that version actually vulnerable?

Possibly not: distributions patch old version numbers without changing them. But scanners and attackers cannot tell, so your site will still be flagged in every audit, and the header also reveals your operating system. Hide it either way.

4. I set server_tokens off but the version still shows. Why?

Common causes: the directive is in a server block that is not the one answering, nginx was not reloaded, or the response comes from a different layer, such as an upstream application, a second proxy or a CDN. Check the header on both the home page and a missing page, then trace which layer adds it.

5. Why do I need to check a 404 page as well?

Default error pages are generated by the web server itself and often print the full version in the page body (for example "Apache/2.4.29 (Ubuntu) Server at example.com Port 443"), even when the home page looks clean. Scanners request a missing page specifically to read this.