1.1隐藏Nginx header里版本号信息
1、查看版本号
curl -I 127.0.0.1HTTP/1.1 200 OKServer: nginx/1.6.2Date: Sat, 14 Mar 2015 08:15:29 GMTContent-Type: text/htmlContent-Length: 25Last-Modified: Fri, 13 Mar 2015 10:52:27 GMTConnection: keep-aliveETag: "5502c16b-19"Accept-Ranges: bytes
2、隐藏版本号
在nginx配置文件的http标签内加入“server_tokens off; ”参数,也可以放大server标签和location标签中,如下:
http {..........server_tokens off;..........}/application/nginx/sbin/nginx -t/application/nginx/sbin/nginx -s reload
再此查看如下,浏览器访问错误页面也就没有版本号了
curl -I 127.0.0.1HTTP/1.1 200 OKServer: nginx
1.2更改源码隐藏软件名称及版本号
在nginx编译安装之前,先更改,之后再编译安装
1、更改版本号,修改nginx-1.3.4/src/core/nginx.h
cd /home/memory/tools/cd nginx-1.6.2/src/coresed -n '13,17p'nginx.h#define NGINX_VERSION "1.6.2" 修改为想要的版本号如2.4.3#define NGINX_VER "nginx/" NGINX_VERSION 将nginx修改为想要修改的软件名称,如Apache。
修改后查看header结果:
curl -I 10.0.0.182HTTP/1.1 200 OKServer:Apache/2.4.3
2、修改nginx-1.6.12/src/http/ngx_http_header_filter_module.c需要修改的字符串
grep 'Server:nginx' ngx_http_header_filter_module.cstatic char ngx_http_server_string[] ="Server:nginx" CRLF;sed -i 's#Server:nginx#Server:Apache#g' ngx_http_header_filter_module.c
修改后的字符串
grep 'Server:Apache' ngx_http_header_filter_module.cstatic char ngx_http_server_string[] ="Server:Apache" CRLF;
3、修改ngx_http_special_response.c
vi nginx-1.3.4/src/http/ngx_http_special_response.cstatic u_char ngx_http_error_full_tail[]=""NGINX_VER" "CRLF"