Nginx隐藏响应头信息的Server信息和版本信息
问题如下

解决办法
- 隐藏nginx版本信息
nginx/conf/nginx.conf
http {
...
server_tokens off
...
}

- 隐藏server信息
实现方案:需要重新编译nginx
进入解压出来的nginx源码目录(不是nginx的安装目录)
vim 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: Web" CRLF;static char ngx_http_server_full_string[] = "Server:Web " CRLF;
修改完后重新编译nginx,再看header里面Server信息变成了自定义的信息,不再显示nginx信息了。

浙公网安备 33010602011771号