# Server header: how to hide your web server version

> Why WebSec0 takes 5 points for a version in the Server header, and tested fixes for Nginx, Apache, Caddy, Traefik, PHP and Express, proxied backends included.

Author: Joshua Martinelle, Security engineer at Tenable (https://www.websec0.com/guides/authors/joshua-martinelle/)
Canonical: https://www.websec0.com/guides/server/
Updated: 2026-11-03
Tested on: nginx 1.28 to 1.31, Apache httpd 2.4.58 to 2.4.69, Caddy 2.9 to 2.11, Traefik 2.11 to 3.7, PHP 8.3 and 8.4, and Express 5.3

## In short

- The `Server` header names the software that answered the request. Keep the name if you like, but remove the version: `server_tokens off` in Nginx, `ServerTokens Prod` in Apache.
- WebSec0 takes 5 points off the headers score when the `Server` header on your home page contains a digit or a `/`.
- Behind a reverse proxy, the version often comes from the backend. Apache, Caddy and Traefik pass the backend's `Server` header on, so remove it at the proxy.
- Hiding the version fixes no vulnerability. It makes automated version matching harder; keeping the software patched is what protects the server.

## What does the Server header reveal?

The **`Server`** response header names the software that answered the
request. By default, Nginx and Apache add their exact version. Apache also
adds the operating system family and, with `mod_ssl`, the OpenSSL version:

```http
Server: nginx/1.31.8
Server: Apache/2.4.69 (Unix) OpenSSL/3.5.7
```

To hide the version, set `server_tokens off` in Nginx or `ServerTokens Prod`
in Apache. The header then reads `nginx` or `Apache`. If a reverse proxy sits
in front of an application server, check the backend's header too: several
proxies pass it on unchanged.

## Does hiding the version make a server more secure?

Not by itself. The
[Apache documentation](https://httpd.apache.org/docs/2.4/mod/core.html#servertokens)
says that disabling the header does nothing to make a server more secure, and
calls security through obscurity a myth. A server with a known hole is just as
vulnerable without the banner.

The version still helps whoever is looking for that hole.
[RFC 9110](https://www.rfc-editor.org/rfc/rfc9110#field.server) says a server
should not send needlessly fine-grained detail, since it may make known
security holes slightly easier to find and exploit. A scanner that searches
the web for one vulnerable version reads it straight from the header. The
[OWASP testing guide](https://wstg.owasp.org/latest/4-Web_Application_Security_Testing/01-Information_Gathering/02-Fingerprint_Web_Server)
shows how to fingerprint a server without it, so the product name is not
worth hiding. The version is, because it costs nothing to remove.

## How WebSec0 grades the Server header

`Server` is not one of the six graded headers. WebSec0 reads it on the
response to your home page, after following redirects on the same host, and
applies a penalty to the headers score:

| `Server` value on the home page | Effect |
| --- | --- |
| Contains a digit or a `/`, such as `nginx/1.31.8` | −5, shown as "Server header discloses version" |
| A name without digits, such as `nginx`, `Apache` or `cloudflare` | Shown, no penalty |
| No header | Nothing |

The test is a simple pattern, not a list of products: `web01` or
`ECS (nyb/1D2E)` cost 5 points as well. With all six security headers passing,
the penalty takes the score from 100 to 95, still an A+. Anywhere else it can
cost a grade: a site at 87 (A) with a partial Content-Security-Policy drops to
82, a B.

WebSec0 reads only the first `Server` line. If a response carries two, as
Caddy 2.9 sends behind a proxy (see below), the second one is not graded, but
it still reveals the version.

## Find what your server sends

Check the home page and a page that does not exist, since error pages
sometimes come from another layer. Use your own URL:

```sh
curl -sI https://example.com/ | grep -iE "^(server|x-powered-by):"
curl -sI https://example.com/no-such-page | grep -iE "^(server|x-powered-by):"
```

Then fix the header where it is set. On a single server, that is the server's
own setting. Behind a reverse proxy, the value may come from the backend: the
sections below show what each proxy does with it.

## Nginx

Add `server_tokens off` to the `http` block of `/etc/nginx/nginx.conf`:

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

On nginx 1.28, 1.30 and 1.31, the header became `Server: nginx`, and the
error page that Nginx writes itself for a malformed request no longer
showed the version. Set it in `http`, not in one `server` block. In our test
with the directive in one server block only, a request for another host name
and a malformed request still returned `Server: nginx/1.31.8`: Nginx handled
them in the default server.

As a reverse proxy, Nginx does not pass the backend's `Server` header on. The
[`proxy_hide_header` documentation](https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_hide_header)
lists it among the headers dropped by default. It does pass
`X-Powered-By`, so hide that one yourself:

```nginx
location / {
    proxy_pass http://127.0.0.1:8080;
    proxy_hide_header X-Powered-By;
}
```

Open-source Nginx always sends `nginx`. The documentation describes a custom
value as part of its commercial subscription. `nginx` has no digit
or `/`, so WebSec0 does not penalise it.

## Apache

Set `ServerTokens Prod` in the main configuration, outside any
`<VirtualHost>`. On Debian and Ubuntu, edit the lines that already exist in
`/etc/apache2/conf-available/security.conf`, which ships with
`ServerTokens OS` and `ServerSignature On`:

```apache
ServerTokens Prod
ServerSignature Off
```

The header becomes `Server: Apache`. Apache's default is `Full`, which adds
the version and the operating system family. On httpd 2.4.58, 2.4.62 and
2.4.69, `ServerTokens` inside a virtual host stopped Apache from starting:

```sh
AH00526: Syntax error on line 3 of /usr/local/apache2/conf/site.conf:
ServerTokens cannot occur within <VirtualHost> section
```

`ServerSignature Off` is Apache's default. It removes the footer that names
the server at the bottom of Apache's error pages; with `On`, the footer read
"Apache Server at example.com Port 80" once `ServerTokens Prod` was set.

As a reverse proxy, Apache passes the backend's `Server` header on.
`ServerTokens Prod` does not change it: in our tests, the home page still
returned `Server: nginx/1.31.8` from the backend. Remove it with
`Header unset`:

```apache
<VirtualHost *:443>
    ServerName example.com
    # ...
    ProxyPass "/" "http://127.0.0.1:8080/"
    Header unset Server
    Header unset X-Powered-By
</VirtualHost>
```

Apache then sends its own `Server: Apache`. Use `Header unset`, not
`Header always unset`: the backend's headers sit in the table that
`Header unset` edits, and with `always`, the backend's version stayed.

## Caddy

Caddy sends `Server: Caddy`, with no version, so a site that Caddy serves
alone passes. Behind `reverse_proxy`, the backend's header reaches the
client. Caddy 2.10 and 2.11 sent only the backend's `Server: nginx/1.31.8`.
Caddy 2.9 sent two lines, `Server: Caddy` then the backend's. Remove the
backend's headers in the `reverse_proxy` block:

```caddyfile
example.com {
	reverse_proxy 127.0.0.1:8080 {
		header_down -Server
		header_down -X-Powered-By
	}
}
```

With this block, Caddy 2.10 and 2.11 sent no `Server` header at all, and
Caddy 2.9 sent `Server: Caddy` alone. Both pass. To remove the header from
every response of the site, including those Caddy serves itself, use
`header -Server` in the site block instead.

## Traefik

Traefik adds no `Server` header of its own: it passes the backend's on
unchanged. Remove it, and `X-Powered-By`, with a `headers` middleware. An
empty value deletes the header:

```yaml
http:
  middlewares:
    hide-server:
      headers:
        customResponseHeaders:
          Server: ""
          X-Powered-By: ""

  routers:
    site:
      rule: "Host(`example.com`)"
      entryPoints: [websecure]
      tls: {}
      service: backend
      middlewares: [hide-server]
```

On Traefik 2.11, 3.6 and 3.7, the responses then carried no `Server` or
`X-Powered-By` header. Traefik's own 404 for an unknown host has no
`Server` header either. If you already use a security headers middleware, add
the two lines to its `customResponseHeaders`.

## Remove X-Powered-By in the application

WebSec0 does not grade `X-Powered-By`, but it reveals the same detail as a
versioned `Server` header. Removing it in the application covers every proxy.

PHP adds `X-Powered-By: PHP/8.4.27` while
[`expose_php`](https://www.php.net/manual/en/ini.core.php#ini.expose-php) is
on. It is on by default, and the `php.ini-production` file shipped with
PHP 8.3 and 8.4 also sets `expose_php = On`. Turn it off in `php.ini`, or in
a file of the `conf.d` directory:

```ini
expose_php = Off
```

On PHP 8.3 and 8.4, the header was gone once the file was loaded. Restart
PHP-FPM or the web server after the change.

Express adds `X-Powered-By: Express`. The
[Express security guide](https://expressjs.com/en/advanced/best-practice-security.html#reduce-fingerprinting)
recommends disabling it:

```js
const app = express();
app.disable('x-powered-by');
```

On Express 5.3, the header was gone. As the Express guide notes, this only
hides the banner: the framework can still be identified in other ways.

## Verify it

Run the same requests again on the home page and on a missing page:

```sh
curl -sI https://example.com/ | grep -iE "^(server|x-powered-by):"
curl -sI https://example.com/no-such-page | grep -iE "^(server|x-powered-by):"
```

Each should print at most a name without a version, such as `server: nginx`,
and no `x-powered-by` line. The headers are not the only place the version
shows: a backend's own error pages can print it in the page body, which a
proxy passes on as is. In our tests, a 404 from an Nginx backend still showed
`nginx/1.31.8` at the bottom of the page behind every proxy, so set
`server_tokens off` on the backend too. Then scan the site with WebSec0; the
headers report lists `Server` under the additional headers.

## Frequently asked questions

### How do I hide the Nginx version in the Server header?

Add `server_tokens off;` to the `http` block of `nginx.conf` and reload. Nginx then sends `Server: nginx` and leaves the version out of its own error pages. Set it in `http`, not in one `server` block, or the other server blocks still show the version.

### How do I hide the Apache version?

Set `ServerTokens Prod` in the main configuration, outside any `<VirtualHost>`: Apache then sends `Server: Apache`. Inside a virtual host, Apache refuses to start. If Apache proxies to a backend, also add `Header unset Server`, because it passes the backend's header on.

### Why does WebSec0 still flag my Server header after server_tokens off?

The header probably does not come from the server you changed. A backend behind Apache, Caddy or Traefik, or a CDN in front of your server, can send its own. WebSec0 also flags any digit or `/`, so a custom value such as `web01` costs 5 points too.

### Does WebSec0 check X-Powered-By?

No. Only the `Server` header affects the score. `X-Powered-By` reveals the same kind of detail, such as `PHP/8.4.27`, so remove it too: `expose_php = Off` in PHP, `app.disable('x-powered-by')` in Express.

### Can I remove the Server header completely?

Caddy can, with `header -Server`, and Traefik does not add one. Open-source Nginx always sends `nginx`; the nginx documentation describes a custom value as part of its commercial subscription. Apache's shortest value is `Apache`.

### Is hiding the server version security through obscurity?

Yes. The Apache documentation says that disabling the header does nothing to make a server more secure. RFC 9110 still advises against needlessly detailed values, because they make known holes slightly easier to find. Hide the version, and keep patching.

## Sources

- [RFC 9110: HTTP Semantics, section 10.2.4 (Server)](https://www.rfc-editor.org/rfc/rfc9110#field.server), IETF
- [Module ngx_http_core_module: server_tokens](https://nginx.org/en/docs/http/ngx_http_core_module.html#server_tokens), nginx.org
- [Module ngx_http_proxy_module: proxy_hide_header](https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_hide_header), nginx.org
- [Apache core features: ServerTokens](https://httpd.apache.org/docs/2.4/mod/core.html#servertokens), Apache HTTP Server Project
- [Apache core features: ServerSignature](https://httpd.apache.org/docs/2.4/mod/core.html#serversignature), Apache HTTP Server Project
- [Caddyfile reverse_proxy: headers](https://caddyserver.com/docs/caddyfile/directives/reverse_proxy#headers), Caddy
- [Traefik Proxy: Headers middleware](https://doc.traefik.io/traefik/reference/routing-configuration/http/middlewares/headers/), Traefik Labs
- [PHP core configuration: expose_php](https://www.php.net/manual/en/ini.core.php#ini.expose-php), PHP Documentation
- [Production best practices: security (Reduce fingerprinting)](https://expressjs.com/en/advanced/best-practice-security.html#reduce-fingerprinting), Express
- [WSTG-INFO-02: Fingerprint Web Server](https://wstg.owasp.org/latest/4-Web_Application_Security_Testing/01-Information_Gathering/02-Fingerprint_Web_Server), OWASP
