Simple Apache Security Trick – ServerTokens & ServerSignature

Want to help support this blog? Try out Oh Dear, the best all-in-one monitoring tool for your entire website, co-founded by me (the guy that wrote this blogpost). Start with a 10-day trial, no strings attached.

We offer uptime monitoring, SSL checks, broken links checking, performance & cronjob monitoring, branded status pages & so much more. Try us out today!

Profile image of Mattias Geniar

Mattias Geniar, September 09, 2008

Follow me on Twitter as @mattiasgeniar

In a normal Apache installation, your config-file will look like this.

#
# ServerTokens
# This directive configures what you return as the Server HTTP response
# Header. The default is 'Full' which sends information about the OS-Type
# and compiled in modules.
# Set to one of:  Full | OS | Minor | Minimal | Major | Prod
# where Full conveys the most information, and Prod the least.
#
ServerTokens Full

#
# Optionally add a line containing the server version and virtual host
# name to server-generated pages (internal error documents, FTP directory
# listings, mod_status and mod_info output etc., but not CGI generated
# documents or custom error documents).
# Set to "EMail" to also include a mailto: link to the ServerAdmin.
# Set to one of:  On | Off | EMail
#
ServerSignature On

This will produce the following default error-message (ie: when a .htaccess creates an error).

Internal Server Error

Apache/2.2.3 (Debian) PHP/5.2.0-8+etch11 Server at [servername] Port 80

For a production server, that’s quite a bit of information you’re giving away there – especially the exact version-number of the OS & Apache, which could expose potential leaks/unpatched bugs.

It’s better to change this to:

# ...
ServerTokens Prod

# ...
ServerSignature Off

This will remove the last line of the error-message, where the Apache & OS-version are shown – thus increase your security.

It’s of course 100x more important to keep your software up-to-date, but hiding the version you’re using could help – even if it isn’t by much.



Want to subscribe to the cron.weekly newsletter?

I write a weekly-ish newsletter on Linux, open source & webdevelopment called cron.weekly.

It features the latest news, guides & tutorials and new open source projects. You can sign up via email below.

No spam. Just some good, practical Linux & open source content.