Apache不显示服务器头信息

Apache/2.2.14 (CentOS) Server at blog.const.net.cn Port 80
当使用一些查看服务器头信息(Server header)的工具,也能够详细显示出服务器的Server信息,与上面类似。

Apache不显示服务器头信息_第1张图片

Date: Thu, 22 Jan 2014 17:01:20 GMT
Server: Apache/2.2.15 (CentOS)
Last-Modified: Thu, 22 Jan 2014 17:01:20 GMT
Etag: "5a503ce-4c41-4ad803043a000"
Accept-Ranges: bytes
Vary: Accept-Encoding
Content-Encoding: gzip
Content-Length: 5312
Content-Type: text/html

如何关闭这些显示呢?网上很多说法都是说要自己修改并重新编译源代码才可以。其实有更简单的办法可以实现。

在Apache 的http.conf中添加如下二条即可:

ServerSignature Off
ServerTokens Prod

其中,ServerSignature Off告诉Apache在错误页(HTTP Status 404之类)不显示服务器版本信息,但此选项不影响可正常访问的页面(HTTP Status 200之类)。正常访问网页的Server Header里面依然有服务器版本信息。
ServerTokens Prod告诉Apache在服务器头信息中(Server Header)中只返回Apache,不返回服务器操作系统与Apache的版本信息。

配置保存后,Apache reload或者Apache restart就可以生效了。

你可能感兴趣的:(Apache不显示服务器头信息)