1.隐藏Apache版本信息
测试默认 apache 的状态信息
[root@1314it conf]# curl -Is localhost
HTTP/1.1 200 OK
Date: Tue, 16 Nov 2010 04:20:15 GMT
Server: Apache/2.2.3 (CentOS) DAV/2 PHP/5.1.6 mod_perl/2.0.4 Perl/v5.8.8
X-Powered-By: PHP/5.1.6
Connection: close
Content-Type: text/html; charset=GB2312
[root@1314it conf]#
修改主配置文件 httpd.conf
ServerSignature Off
ServerTokens Prod
重启 apache 测试
测试隐藏版本号后 apache 的状态信息
[root@1314it conf]# curl -Is localhost
HTTP/1.1 200 OK
Date: Tue, 16 Nov 2010 04:21:41 GMT
Server: Apache
X-Powered-By: PHP/5.1.6
Connection: close
Content-Type: text/html; charset=GB2312
[root@1314it conf]#
2.伪装Apache版本信息 (需要修改源代码 并重新编译安装)
获取源码
修改 include/ap_release.h文件 "Apache" 参数为 "Microsoft-IIS/5.0"
修改 os/unix/os.h文件 "Unix" 参数为 "Win32"
# 2.2.17 (released 2010-10-19)
mkdir /tmp/download
cd /tmp/download
wget http://labs.renren.com/apache-mirror//httpd/httpd-2.2.17.tar.bz2
tar -jxf httpd-2.2.17.tar.bz2
cd httpd-2.2.17
include/ap_release.h
#define AP_SERVER_BASEPRODUCT "Apache"
改为
#define AP_SERVER_BASEPRODUCT "Microsoft-IIS/5.0"
# 使用 sed 流编辑工具修改
sed -i 's/#define AP_SERVER_BASEPRODUCT "Apache"/#define AP_SERVER_BASEPRODUCT "Microsoft-IIS/5.0"/g' include/ap_release.h
os/unix/os.h
#define PLATFORM "Unix"
改成
#define PLATFORM "Win32"
sed -i 's/#define PLATFORM "Unix"/#define PLATFORM "Win32"/g' os/unix/os.h
./configure
make
make install
修改主配置文件 /usr/local/apache2/conf/httpd.conf
添加
ServerSignature Off
ServerTokens Prod
启动apache
/usr/local/apache2/bin/apachectl start
# 测试 使用curl获取服务器信息
[root@1314it conf]# curl -Is localhost
HTTP/1.1 200 OK
Date: Tue, 16 Nov 2010 04:06:21 GMT
Server: Microsoft-IIS/5.0
Last-Modified: Sat, 20 Nov 2004 20:16:24 GMT
ETag: "d8514-2c-3e9564c23b600"
Accept-Ranges: bytes
Content-Length: 44
Content-Type: text/html
[root@1314it conf]#
# 相关资料
ServerSignature 配置服务器生成页面的页脚
语法 ServerSignature On|Off|EMail
默认值 ServerSignature Off
作用域 server config, virtual host, directory, .htaccess
覆盖项 All
ServerTokens 配置"Server:"应答头
语法 ServerTokens Major|Minor|Min[imal]|Prod[uctOnly]|OS|Full
默认值 ServerTokens Full
作用域 server config
这个指令控制了服务器回应给客户端的"Server:"应答头是否包含关于服务器操作系统类型和编译进的模块描述信息。
ServerTokens Prod[uctOnly]
服务器会发送(比如): Server: Apache
ServerTokens Major
服务器会发送(比如): Server: Apache/2
ServerTokens Minor
服务器会发送(比如): Server: Apache/2.0
ServerTokens Min[imal]
服务器会发送(比如): Server: Apache/2.0.41
ServerTokens OS
服务器会发送(比如): Server: Apache/2.0.41 (Unix)
ServerTokens Full (或未指定)
服务器会发送(比如): Server: Apache/2.0.41 (Unix) PHP/4.2.2 MyMod/1.2
官方文档(cn) http://lamp.linux.gov.cn/Apache/ApacheMenu/index.html
来自:http://www.python-cn.cn
sheng_notes