码迷,mamicode.com
首页 > 其他好文 > 详细

nginx隐藏server信息和版本信息

时间:2018-05-02 11:17:21      阅读:140      评论:0      收藏:0      [点我收藏+]

标签:span   off   crlf   col   重新编译   ngnix   lte   mod   需要   

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

  

nginx隐藏server信息和版本信息

标签:span   off   crlf   col   重新编译   ngnix   lte   mod   需要   

原文地址:https://www.cnblogs.com/baby123/p/8978929.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!