1、背景
软件的漏洞都和版本有关,当黑客知道版本号后,可以针对漏洞进行攻击,所以隐藏版本号是保证web服务安全的手段之一
2、隐藏版本号方法
1)通过修改nginx.conf文件,在http标签加上如下字段
server_tokens off
作用:这个参数作用是控制http response header 内的web服务版本信息的显示以及错误信息中的web服务版本信息显示
2)方法二:通过修改源码进行隐藏版本号
需要修改三个文件:
1)nginx-1.6.6/src/core/nginx.h (13/14行)
13 #define NGINX_VERSION “3.13.7”
14 #define NGINX_VER “lxm/” NGINX_VERSION
2) nginx-1.6.4.src/http/ngx_http_header_filter_module.c 49行
49 static u_char ngx_http_server_string[] = “Server: lxm” CRLF;
3)nginx-1.6.4.src/http/ngx_http_special_response.c 36行
36 “
备注:修改字符前为行号
然后进行预编译、编译,复制nginx 执行文件,重启即可