nginx隐藏server信息和版本信息

1.隐藏版本信息

在nginx.conf里面添加

server_tokens off;

2.隐藏server信息

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

vi src/http/ngx_http_header_filter_module.c

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信息变成了自定义的名字 X-Web

  

posted @ 2018-05-02 10:02  慕尘  阅读(7931)  评论(0编辑  收藏  举报