[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"article-8":3},{"id":4,"title":5,"title_en":6,"abstract":7,"abstract_en":8,"content":9,"content_en":10,"category":11,"banner_id":12,"banner_path":13,"tags":14,"is_recommend":17,"prev_article":18,"next_article":22,"created_at":26},8,"修复HTTP头信息泄露Nginx版本信息漏洞","Fixed vulnerability where HTTP header information leaked Nginx version information","#### - 修复方法分为两种：\n\t1. 直接隐藏掉nginx的版本信息\n\t2. 修改web服务器所使用的nginx的名称和版本信息\n#### 1.直接隐藏掉nginx的版本信息\n```shell\n#","#### -There are two repair methods:\n\t1. Directly hide nginx version information\n\t2. Modify the name and version information of the nginx used by the web server\n#### 1. Directly hide nginx version information\n```shell\n#","#### - 修复方法分为两种：\n\t1. 直接隐藏掉nginx的版本信息\n\t2. 修改web服务器所使用的nginx的名称和版本信息\n#### 1.直接隐藏掉nginx的版本信息\n```shell\n# 添加内容\n[root@VM_0_12_centos conf]# vim nginx.conf\nserver_tokens off;\n```\n```shell\n 浏览器控制台抓包可以看到：\n **Response Headers**\n\tAccept-Ranges: bytes\n\tContent-Length: 739\n\tContent-Type: text\u002Fhtml\n\tDate: Tue, 30 Jun 2020 07:53:36 GMT\n\tETag: \"5e9bc167-2e3\"\n\tLast-Modified: Sun, 19 Apr 2020 03:11:35 GMT\n\tServer: nginx\n```\n#### 2.修改web服务器所使用的nginx的名称和版本信息\n\n```shell\n（1）一共需要修改三个文件。包括：\n\n    ·src\u002Fcore目录下的nginx.h文件\n    ·src\u002Fhttp目录下的ngx_http_header_filter_module.c文件\n    ·src\u002Fhttp目录下的ngx_http_special_response.c文件\n\n（2）修改内容如下：\n [root@VM_0_12_centos core]# vim nginx.h\n #define NGINX_VERSION      \"\" \n #define NGINX_VER          \"CSDN\" NGINX_VERSION\n \n [root@VM_0_12_centos http]# vim ngx_http_header_filter_module.c\n static u_char ngx_http_server_string[] = \"Server: CSDN\" CRLF;\n \n [root@VM_0_12_centos http]# vim ngx_http_special_response.c\n static u_char ngx_http_error_tail[] =\n \"\u003Chr>\u003Ccenter>CSDN\u003C\u002Fcenter>\" CRLF\n \"\" CRLF\n \"\" CRLF\n\n (3) 重新编译nginx并启动\n     [root@VM_0_12_centos nginx]# .\u002Fconfigure --prefix=\u002Fusr\u002Flocal\u002Fnginx\n \t [root@VM_0_12_centos nginx]# make &amp;&amp; make install\n \t [root@VM_0_12_centos sbin]# kill -9 PID\n \t [root@VM_0_12_centos sbin]# .\u002Fnginx -c\n\n\u002Fusr\u002Flocal\u002Fnginx\u002Fconf\u002Fnginx.conf  #重新加载配置文件并启动\n\n（4）浏览器控制台抓包可以看到：\n  **Response Headers**\n \tAccept-Ranges: bytes\n \tContent-Length: 739\n \tContent-Type: text\u002Fhtml\n \tDate: Tue, 30 Jun 2020 07:53:36 GMT\n \tETag: \"5e9bc167-2e3\"\n \tLast-Modified: Sun, 19 Apr 2020 03:11:35 GMT\n \tServer: CSDN\n```\n#### - 建议大家选择第二种方式，虽然修改的文件以及操作可能多了点，但是第二种相对于第一种更安全一些。\n\n\n\n### 原文链接：[修复HTTP头信息泄露Nginx版本信息漏洞](https:\u002F\u002Fblog.csdn.net\u002Fxiaoleilei666\u002Farticle\u002Fdetails\u002F107065075 \"修复HTTP头信息泄露Nginx版本信息漏洞\")","#### -There are two repair methods:\n\t1. Directly hide nginx version information\n\t2. Modify the name and version information of the nginx used by the web server\n#### 1. Directly hide nginx version information\n```shell\n#Add content\n[root@VM_0_12_centos conf]# vim nginx.conf\nserver_tokens off;\n```\n```shell\n When you grab the bag on the browser console, you can see:\n **Response Headers**\n\tAccept-Ranges: bytes\n\tContent-Length: 739\n\tContent-Type: text\u002Fhtml\n\tDate: Tue, 30 Jun 2020 07:53:36 GMT\n\tETag: \"5e9bc167-2e3\"\n\tLast-Modified: Sun, 19 Apr 2020 03:11:35 GMT\n\tServer: nginx\n```\n#### 2. Modify the name and version information of the nginx used by the web server\n\n```shell\n(1) A total of three documents need to be revised. Including:\n\n    ·nginx.h file in src\u002Fcore directory\n    ·File ngx_http_header_filter_module.c in src\u002Fhttp directory\n    ·ngx_http_special_response.c file in src\u002Fhttp directory\n\n(2) The modification is as follows:\n [root@VM_0_12_centos core]# vim nginx.h\n #define NGINX_VERSION      \"\" \n #define NGINX_VER          \"CSDN\" NGINX_VERSION\n \n [root@VM_0_12_centos http]# vim ngx_http_header_filter_module.c\n static u_char ngx_http_server_string[] = \"Server: CSDN\" CRLF;\n \n [root@VM_0_12_centos http]# vim ngx_http_special_response.c\n static u_char ngx_http_error_tail[] =\n \"\u003Chr>\u003Ccenter>CSDN\u003C\u002Fcenter>\" CRLF\n \"\" CRLF\n \"\" CRLF\n\n (3)Recompile nginx and launch\n     [root@VM_0_12_centos nginx]# .\u002F configure --prefix=\u002Fusr\u002Flocal\u002Fnginx\n \t [root@VM_0_12_centos nginx]# make &amp;&amp; make install\n \t [root@VM_0_12_centos sbin]# kill -9 PID\n \t [root@VM_0_12_centos sbin]# .\u002F nginx -c\n\n\u002Fusr\u002Flocal\u002Fnginx\u002Fconf\u002Fnginx.conf #Reload the configuration file and boot\n\n(4) When you grab the bag on the browser console, you can see:\n  **Response Headers**\n \tAccept-Ranges: bytes\n \tContent-Length: 739\n \tContent-Type: text\u002Fhtml\n \tDate: Tue, 30 Jun 2020 07:53:36 GMT\n \tETag: \"5e9bc167-2e3\"\n \tLast-Modified: Sun, 19 Apr 2020 03:11:35 GMT\n \tServer: CSDN\n```\n#### -I suggest you choose the second method. Although there may be more files and operations to modify, the second method is safer than the first method.\n\n\n\n### Original link: [Fix the vulnerability of HTTP header information leaking Nginx version information](blog.csdn.net\u002Fxiaoleilei666\u002Farticle\u002Fdetails\u002F107065075 \"Fix the vulnerability of HTTP header information leaking Nginx version information\")","部署",0,"https:\u002F\u002Fblog4-1316398321.cos.ap-nanjing.myqcloud.com\u002Fblog5\u002F20250707081116__freecompress-【哲风壁纸】暗黑御姐风-酷酷的少女.png",[15,16],"Linux","Nginx",false,{"id":19,"title":20,"title_en":21},6,"关于","Uncle Sam's blog",{"id":23,"title":24,"title_en":25},9,"枫枫知道--Vue全系列课程","Maple Fengfeng knows - Vue full range of courses","2025-07-23T07:04:09+08:00"]