- The
Serverheader names the software that answered the request. Keep the name if you like, but remove the version:server_tokens offin Nginx,ServerTokens Prodin Apache. - WebSec0 takes 5 points off the headers score when the
Serverheader 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
Serverheader 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:
Server: nginx/1.31.8
Server: Apache/2.4.69 (Unix) OpenSSL/3.5.7To 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 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 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 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:
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:
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
lists it among the headers dropped by default. It does pass
X-Powered-By, so hide that one yourself:
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:
ServerTokens Prod
ServerSignature OffThe 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:
AH00526: Syntax error on line 3 of /usr/local/apache2/conf/site.conf:
ServerTokens cannot occur within <VirtualHost> sectionServerSignature 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:
<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:
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:
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 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:
expose_php = OffOn 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
recommends disabling it:
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:
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.
Questions
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.
References
Sources
- Apache core features: ServerTokensApache HTTP Server Project
- Apache core features: ServerSignatureApache HTTP Server Project
- Traefik Proxy: Headers middlewareTraefik Labs
- PHP core configuration: expose_phpPHP Documentation
