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_915909065 小时前
全面解析前端开发中常用的浏览器调试工具及其使用场景
android·ios·小程序·https·uni-app·iphone·webview
树下水月11 小时前
HTTPS 站点请求 HTTP的API 接口服务报错的问题
网络协议·http·https
XiYang-DING11 小时前
【Java EE】 HTTP协议
java·http·java-ee
皮卡祺q12 小时前
【Java网络编程核心-0】从OSI七层到TCP/IP模型深度解析(HTTP协议、TCP、UDP 、 IP协议)
网络·网络协议·tcp/ip·http·https·udp
gs8014012 小时前
避坑指南:Nginx 多层代理下的“404”与“重定向死循环”深度排查
运维·nginx
相思难忘成疾13 小时前
RHCE 综合实验:基于 Nginx 实现 openlab 多站点部署、用户访问控制与 HTTPS 加密访问
linux·运维·nginx·http·https·rhel
Q_45828386813 小时前
基于 JTT1078MediaServer 的集群方案实践(Nginx + 溯源模式)轻量级车联网音视频集群
运维·服务器·nginx·架构·音视频·交通物流
Howrun77713 小时前
从公钥密码学到 HTTPS:一文读懂数字证书与信任链条
网络协议·http·https
p***769813 小时前
docker compose安装mindoc 后添加https访问反向代理配置教程
jvm·docker·https
weixin_4575072114 小时前
centos安装docker配置自动HTTPS部署多个项目
docker·https·centos