1、隐藏nginx版本信息
在nginx.conf里面加server_tokens off;就可以隐藏版本号。
2、隐藏server信息
实现方案 : 需要重新编译nginx
进入解压出来的nginx 源码 目录(不是nginx的安装目录)
vi src/http/ngx_http_header_filter_module.c # 49-50行
编辑:
内容:
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: X-Web" CRLF;
static char ngx_http_server_full_string[] = "Server:X-Web " CRLF;
修改完后重新编译nginx,再看header里面Server信息变成了自定义的名字,不再显示nginx信息了。
如图: