nginx隐藏server信息和版本信息

1.隐藏版本信息

在nginx.conf里面添加

server_tokens off;

2.隐藏server信息

需要重新编译ngnix
进入解压出来的nginx 源码目录

vi src/http/ngx_http_header_filter_module.c

static u_char ngx_http_server_string[] = "Server: nginx" CRLF;
static u_char ngx_http_server_full_string[] = "Server: " NGINX_VER CRLF;
static u_char ngx_http_server_build_string[] = "Server: " NGINX_VER_BUILD CRLF;

改为

static u_char ngx_http_server_string[] = "Server: X-Web" CRLF;
static u_char ngx_http_server_full_string[] = "Server: X-Web" CRLF;
static u_char ngx_http_server_build_string[] = "Server: X-Web" CRLF;

重新编译nginx

再看header里面Server信息变成了自定义的名字 X-Web

你可能感兴趣的:(Linux)