灯火互联
管理员
管理员
  • 注册日期2011-07-27
  • 发帖数41778
  • QQ
  • 火币41290枚
  • 粉丝1086
  • 关注100
  • 终身成就奖
  • 最爱沙发
  • 忠实会员
  • 灌水天才奖
  • 贴图大师奖
  • 原创先锋奖
  • 特殊贡献奖
  • 宣传大使奖
  • 优秀斑竹奖
  • 社区明星
阅读:1720回复:0

修改nginx服务器类型

楼主#
更多 发布于:2012-08-27 14:52


通常nginx服务器不隐藏服务器类型及版本信息
curl -I http://10.60.30.23

获取web服务器的类型和版本代码  
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;  
49 static char ngx_http_server_full_string[] = “Server: ” NGINX_VER CRLF;  

改为

修改后代码  
48 static char ngx_http_server_string[] = “Server: pws 1.0 ” CRLF;  
49 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  



喜欢0 评分0
游客

返回顶部