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
相关推荐
zru_96025 分钟前
springboot 项目怎样开启https服务
数据库·spring boot·https
多云的夏天7 分钟前
C++-Mongoose(2)-https-server-openssl
开发语言·c++·https
小黄人软件8 分钟前
PCI认证 密钥注入 ECC算法工具 NID_secp521r1 国密算法 openssl 全套证书生成,从证书提取公私钥数组 x,y等
算法·https·ssl
若云止水34 分钟前
ngx_cycle_modules
nginx
龙哥·三年风水2 小时前
ubuntu18-nginx-二进制安装
linux·nginx·ubuntu
耀耀_很无聊4 小时前
03_docker 部署 nginx 配置 HTTPS 并转发请求到后端服务
nginx·docker·https
Aa美少女战士16 小时前
多域名 SSL 证书能保护多少个域名?
网络协议·http·https
CZIDC19 小时前
Nginx搭建API网关服务教程-系统架构优化 API统一管理
运维·nginx·系统架构
爬台阶的蚂蚁20 小时前
搭建docker registry私服,并且支持https推送
docker·容器·https
栩栩云生1 天前
📥 x-cmd install | Slumber - 告别繁琐,拥抱高效的终端 HTTP 客户端
前端·后端·http