This translation has not been editorially reviewed yet. The German version is authoritative. Deutsche Fassung
Software currency
Remove server headers: How does it work with Apache, nginx and PHP?
For Apache, ServerToken’s Prod shortens the header server to the mere name. For nginx, server tokens takes out the version number. For PHP, expose php = Off removes the header X-Powered-By. These lines belong in the configuration of the server, not in the code of the website, and with rented web space, often only the hoster can change them.
Apache: ServerTokens in Main Configuration
In the default setting, ServerTokens is full, the answer is for example "Apache/2.4.2 (Unix) PHP/4.2.2 MyMod/1.2". The minimum level still calls "Apache/2.4.2", only Prod leaves only "Apache" standing. The row applies to the entire server and belongs in the main configuration; It does not work in a.htaccess or a single virtual host. ServerSignature regulates the footer under error pages and is set to Off in the default setting. The manual advises against levels below minimal because troubleshooting between systems becomes more difficult. Address this with your hoster when you request Prod.
nginx: server tokens and the header from PHP
server tokens is on in the default setting and applies to the header server and error pages. With off, the name nginx remains without number. The field can be completely removed via this setting only in the commercial subscription. The row can be in the blocks http, server or location. X-Powered-by comes from the application behind nginx. If PHP runs over FastCGI, fastcgi hide header hides the header; behind a proxy takes over the proxy hide header.
PHP: expose php in the php.ini
PHP writes its version in the header in the default setting, such as "X-Powered-By: PHP/5.3.7". This is only changed in php.ini, with expose php = Off. If you do not have access to the php.ini, Apache helps with a.htaccess with header unset, provided the hoster shares mod headers and the FileInfo permission. Apache keeps separate lists for normal responses and error cases, so both lines are at the bottom of the example.
The line does not close a gap
The Apache manual states: Switching off does not make the server more secure. The RFC 9110 standard says precise specifications made attacks slightly easier, and OWASP recommends removal, with the addition that attackers have other ways to detect. As such, the OWASP test guide lists the order of headers and standard error pages. The intervention therefore belongs in the maintenance next to the update, and the update remains the protective measure.
Examples
Apache: Main configuration
ServerTokens Full
# Antwort: Server: Apache/2.4.2 (Unix) PHP/4.2.2 MyMod/1.2ServerTokens Prod
# Antwort: Server: ApacheActs only in the main configuration and applies to the entire server.
nginx with PHP via FastCGI
http {
server_tokens on;
}http {
server_tokens off;
fastcgi_hide_header X-Powered-By;
}Behind a proxy, the bottom line is proxy hide header X-Powered-By.
Apache: X-Powered by.htaccess
# keine Angabe, PHP meldet: X-Powered-By: PHP/5.3.7Header unset X-Powered-By
Header always unset X-Powered-ByThe top line applies to normal answers, the bottom also in case of error.
- First clarify who is allowed to change the configuration: Hoster, agency or yourself.
- The change takes effect once the service has reloaded the configuration. After that, have a real page and an address checked that does not exist.
- In the browser, press F12, reload the page and open the first request: there are the answer headers.




