Lighttpd、Nginx 、Apache 隐藏响应头信息的Server信息,apache和php的版本信息
web服务器的版本信息
一、隐藏Apache信息
默认情况下,很多Apache安装时会显示版本号及操作系统版本,甚至会显示服务器上安装的是什么样的Apache模块。这些信息可以为黑客所用,并且黑客还可以从中得知你所配置的服务器上的很多设置都是默认状态。
这里有两条语句,需要添加到httpd.conf文件中:
ServerSignature Off
ServerTokens Prod
ServerSignature出现在Apache所产生的像404页面、目录列表等页面的底部。ServerTokens目录被用来判断Apache会在Server HTTP响应包的头部填充什么信息。如果把ServerTokens设为Prod,那么HTTP响应包头就会被设置成:
web服务器的版本信息
一、隐藏Apache信息
默认情况下,很多Apache安装时会显示版本号及操作系统版本,甚至会显示服务器上安装的是什么样的Apache模块。这些信息可以为黑客所用,并且黑客还可以从中得知你所配置的服务器上的很多设置都是默认状态。
这里有两条语句,需要添加到httpd.conf文件中:
ServerSignature Off
ServerTokens Prod
ServerSignature出现在Apache所产生的像404页面、目录列表等页面的底部。ServerTokens目录被用来判断Apache会在Server HTTP响应包的头部填充什么信息。如果把ServerTokens设为Prod,那么HTTP响应包头就会被设置成:
通常nginx服务器不隐藏服务器类型及版本信息
curl -I http://10.60.30.23
HTTP/1.1 200 OK
Server: nginx nginx/0.8.53
Date: Tue, 14 Dec 2010 08:10:06 GMT
Content-Type: text/html
Content-Length: 151
Last-Modified: Mon, 13 Dec 2010 09:39:55 GMT
Connection: keep-alive
Accept-Ranges: bytes
这对于服务器安全来说是个隐患,用以下方法可以改善这种情况
1. 编辑源代码../src/http/ngx_http_header_filter_module.c
48
static char ngx_http_server_string[] = “Server: nginx” CRLF;
static char ngx_http_server_full_string[] = “Server: ” NGINX_VER CRLF;
改为
static char ngx_http_server_string[] = “Server: pws 1.0 ” CRLF;
static char ngx_http_server_full_string[] = “Server: pws 1.0 ” NGINX_VER CRLF;
然后编译安装。
2. 编辑/usr/local/nginx/conf/nginx.conf,添加
server_tokens off;
重新启动nginx
/usr/local/nginx/sbin/nginx -s reload
最终结果如下
curl -I http://10.60.30.23
HTTP/1.1 200 OK
Server: pws 1.0
Date: Tue, 14 Dec 2010 08:24:32 GMT
Content-Type: text/html
Content-Length: 151
Last-Modified: Mon, 13 Dec 2010 09:39:55 GMT
Connection: keep-alive
Accept-Ranges: bytes
curl -I http://10.60.30.23
HTTP/1.1 200 OK
Server: nginx nginx/0.8.53
Date: Tue, 14 Dec 2010 08:10:06 GMT
Content-Type: text/html
Content-Length: 151
Last-Modified: Mon, 13 Dec 2010 09:39:55 GMT
Connection: keep-alive
Accept-Ranges: bytes
这对于服务器安全来说是个隐患,用以下方法可以改善这种情况
1. 编辑源代码../src/http/ngx_http_header_filter_module.c
48
static char ngx_http_server_string[] = “Server: nginx” CRLF;
static char ngx_http_server_full_string[] = “Server: ” NGINX_VER CRLF;
改为
static char ngx_http_server_string[] = “Server: pws 1.0 ” CRLF;
static char ngx_http_server_full_string[] = “Server: pws 1.0 ” NGINX_VER CRLF;
然后编译安装。
2. 编辑/usr/local/nginx/conf/nginx.conf,添加
server_tokens off;
重新启动nginx
/usr/local/nginx/sbin/nginx -s reload
最终结果如下
curl -I http://10.60.30.23
HTTP/1.1 200 OK
Server: pws 1.0
Date: Tue, 14 Dec 2010 08:24:32 GMT
Content-Type: text/html
Content-Length: 151
Last-Modified: Mon, 13 Dec 2010 09:39:55 GMT
Connection: keep-alive
Accept-Ranges: bytes
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: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 测试