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

1. 准备工作

(1)下载最新稳定版nginx包
官网下载地址:https://nginx.org/en/download.html在这里插入图片描述

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

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

2.1 修改以下三个文件:

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

 #define NGINX_VERSION   "" 
 #define NGINX_VER   "CSDN" NGINX_VERSION

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

 static u_char ngx_http_server_string[] = "Server: CSDN" CRLF;

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

 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启停命令

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

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

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
  • 3
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值