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:
# 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
| Header | Example | Sent by |
|---|---|---|
Server | nginx/1.18.0, Apache/2.4.41 (Ubuntu) OpenSSL/1.1.1f | The web server |
X-Powered-By | PHP/7.4.3, Express, ASP.NET, Next.js | Language runtime or framework |
X-AspNet-Version | 4.0.30319 | ASP.NET (.NET Framework) |
X-AspNetMvc-Version | 5.2 | ASP.NET MVC |
X-Generator | Drupal 10 (https://www.drupal.org) | CMS |
Via | 1.1 varnish (Varnish/6.0) | Caches and proxies |
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:
# /etc/nginx/nginx.conf
http {
server_tokens off; # no version in headers or error pages
# ... rest of config
}sudo nginx -t && sudo systemctl reload nginxStock 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:
more_clear_headers Server;Apache
Set these in the main server configuration. They are not allowed in .htaccess. On Debian and Ubuntu, edit /etc/apache2/conf-available/security.conf. On RHEL-based systems, use /etc/httpd/conf/httpd.conf.
# "Server: Apache" with no version, OS or module list
ServerTokens Prod
# No "Apache/2.4.x Server at example.com Port 443" footer on error pages
ServerSignature Offsudo apachectl configtest && sudo systemctl reload apache2 # httpd on RHELApache cannot remove the Server header itself. Header unset Server does not work for it. If you need it gone completely, strip it at your CDN or reverse proxy.
IIS
On IIS 10 (Windows Server 2016 and later), request filtering can remove the header completely. Add this to web.config:
<configuration>
<system.webServer>
<security>
<requestFiltering removeServerHeader="true" />
</security>
</system.webServer>
</configuration>Older IIS versions cannot do this without URL Rewrite. Those versions run on Windows Server releases that are out of support, so upgrading is the better fix.
LiteSpeed
- Open WebAdmin Console → Server Configuration → General.
- Set Server Signature to Hide Full Header (or Hide Version).
- Save and perform a Graceful Restart.
The same setting also controls the X-Turbo-Charged-By header that some LiteSpeed builds send.
Tomcat
In conf/server.xml, hide the version on default error pages using the error report valve inside the <Host> element:
<Host name="localhost" appBase="webapps">
<Valve className="org.apache.catalina.valves.ErrorReportValve"
showReport="false" showServerInfo="false" />
</Host>Tomcat 8.5 and later send no Server header by default. If you see one, remove the server="…" attribute from the <Connector>.
Caddy
Caddy sends Server: Caddy with no version. To remove it completely:
example.com {
header -Server
# ... rest of config
}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):
expose_php = Offsudo systemctl restart php8.3-fpm # match your PHP version, or restart Apache for mod_phpThis 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).
ASP.NET
In web.config, remove X-Powered-By and X-AspNet-Version:
<configuration>
<system.web>
<!-- removes X-AspNet-Version -->
<httpRuntime enableVersionHeader="false" />
</system.web>
<system.webServer>
<httpProtocol>
<customHeaders>
<!-- removes X-Powered-By: ASP.NET -->
<remove name="X-Powered-By" />
</customHeaders>
</httpProtocol>
</system.webServer>
</configuration>For ASP.NET MVC, also remove X-AspNetMvc-Version in Global.asax.cs:
protected void Application_Start()
{
MvcHandler.DisableMvcResponseHeader = true;
// ...
}ASP.NET Core on Kestrel sends Server: Kestrel. Turn it off in Program.cs:
builder.WebHost.ConfigureKestrel(options => options.AddServerHeader = false);Node.js / Express
const express = require('express');
const app = express();
app.disable('x-powered-by'); // removes "X-Powered-By: Express"If you already use Helmet, it removes the header for you.
Next.js
// next.config.mjs
const nextConfig = {
poweredByHeader: false, // removes "X-Powered-By: Next.js"
};
export default nextConfig;WordPress
WordPress itself does not send X-Powered-By; that comes from PHP (see the PHP tab). WordPress does print its version in a generator tag in the page source. Remove it in your theme's functions.php or a small plugin:
// Remove the WordPress version from pages and RSS feeds
add_filter('the_generator', '__return_empty_string');At the proxy
If you cannot change the application, strip the headers at the web server or reverse proxy in front of it.
# Nginx in front of PHP-FPM
fastcgi_hide_header X-Powered-By;
# Nginx in front of an HTTP upstream (Node, Java, .NET...)
proxy_hide_header X-Powered-By;
proxy_hide_header X-AspNet-Version;
proxy_hide_header X-AspNetMvc-Version;# Apache (mod_headers): "always" also covers error responses
Header always unset X-Powered-By
Header unset X-Powered-ByServer 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) andshowServerInfo="false"(Tomcat) cover the built-in pages. A custom 404 and 500 page is even better. - Debug mode. Django's
DEBUG = True, Laravel'sAPP_DEBUG=true, the Symfony profiler (X-Debug-Tokenheader) 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-Serveror aViaheader that names your internal machines map your network for an attacker. Remove them at the load balancer. - CMS generator tags.
<meta name="generator">andX-Generatorheaders.
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:
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 outputThen confirm with the ShowDNS tools, which all apply the same checks:
- Server Signature Test: the full disclosure audit, including the error page.
- Security Headers Checker: disclosure plus your protective headers (HSTS, CSP and others).
- HTTP Header Checker: every response header, with leaking ones marked.
- Web Security Scorecard: a graded overview of headers, TLS and more.
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.