nginx安装升级修复HTTP头信息泄露Nginx版本信息漏洞(并保持https配置)

文章目录

  • [1. 准备工作](#1. 准备工作)
  • [2. 修改web服务器所使用的nginx的名称和版本信息](#2. 修改web服务器所使用的nginx的名称和版本信息)
    • [2.1 修改以下三个文件:](#2.1 修改以下三个文件:)
      • [(1) ·src/core目录下的nginx.h文件](#(1) ·src/core目录下的nginx.h文件)
      • [(2) ·src/http目录下的ngx_http_header_filter_module.c文件](#(2) ·src/http目录下的ngx_http_header_filter_module.c文件)
      • [(3) ·src/http目录下的ngx_http_special_response.c文件](#(3) ·src/http目录下的ngx_http_special_response.c文件)
  • [2.2 重新编译nginx](#2.2 重新编译nginx)
  • [2.3 nginx启停命令](#2.3 nginx启停命令)
  • 2.4浏览器控制台抓包可以看到:

1. 准备工作

(1)下载最新稳定版nginx包

官网下载地址:https://nginx.org/en/download.html![在这里插入图片描述](https://img-blog.csdnimg.cn/direct/bb4dbd80e1f2471aac035b7882492a60.png)

(2)将nginx包拷贝到服务器并解压(# 解压到当前目录下tar -zxvf 资源包)
(3)备份服务器nginx.conf文件、ssl证书文件

2. 修改web服务器所使用的nginx的名称和版本信息

2.1 修改以下三个文件:

(1) ·src/core目录下的nginx.h文件

xml 复制代码
 #define NGINX_VERSION   "" 
 #define NGINX_VER   "CSDN" NGINX_VERSION

(2) ·src/http目录下的ngx_http_header_filter_module.c文件

xml 复制代码
 static u_char ngx_http_server_string[] = "Server: CSDN" CRLF;

(3) ·src/http目录下的ngx_http_special_response.c文件

xml 复制代码
 static u_char ngx_http_error_tail[] =
 "<hr><center>CSDN</center>" CRLF
 "</body>" CRLF
 "</html>" CRLF

2.2 重新编译nginx

(1)进入安装包目录:/home/nginx1.16.1

(2)./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module

(3)make && make install

2.3 nginx启停命令

xml 复制代码
 cd /usr/local/nginx/sbin/
./nginx   #启动
./nginx -s stop  #停止
./nginx -s quit  #退出
./nginx -s reload  #重启  修改配置后重新加载生效
./nginx -s reopen :重新打开日志文件

2.4浏览器控制台抓包可以看到:

xml 复制代码
HTTP/1.1 200
Server: CSDN
Date: Wed, 03 Jul 2024 09:40:49 GMT
Content-Type: application/json
Transfer-Encoding: chunked
Connection: keep-alive
相关推荐
2501_9160088915 分钟前
不连 Xcode,也能把 iPhone App 的实时日志看清楚
android·ios·小程序·https·uni-app·iphone·webview
Linux运维技术栈28 分钟前
Gravitee Kafka Gateway 规范部署:HTTP API化封装与安全隔离实践
http·kafka·gateway
三两肉14 小时前
HTTP/1.1到HTTP/3:互联网通信协议的三代演进之路
网络·网络协议·http·http3·http2·http1.1
三两肉14 小时前
HTTP 缓存详解
网络协议·http·缓存
工具罗某人15 小时前
docker快速部署minio
java·nginx·docker
Violet_YSWY17 小时前
理解:ssh http ftp基于tcp
tcp/ip·http·ssh
oMcLin17 小时前
如何在Ubuntu 24.04上通过配置Nginx与Keepalived实现高可用负载均衡集群
nginx·ubuntu·负载均衡
2501_9447114318 小时前
理清 https 的加密逻辑
网络协议·http·https
源远流长jerry18 小时前
TCP 协议深度指南:历史、设计哲学、报文格式与 tcpdump 抓包实战
网络·网络协议·tcp/ip·http·tcpdump
小Ti客栈19 小时前
前后台Nginx部署同域名路径区分配置
java·前端·nginx