文章目录
- [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包
(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>" CRLF2.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