nginx如何隐藏版本号
本文将介绍如何隐藏Nginx版本号
环境: Centos7,nginx1.24.0
1.隐藏nginx版本号
2.修改nginx版本号
隐藏修改Nginx版本号的主要作用是提高服务器的安全性,防止特定版本的漏洞被攻击者利用。
一、隐藏nginx版本号
1.修改nginx的配置文件。
vim /apps/nginx/conf/nginx.conf
2.重新加载配置文件
systemctl reload nginx
3.测试访问
下图为修改前访问结果
二、修改nginx版本号
1.修改配置文件
vim /usr/local/src/nginx-1.24.0/src/core/nginx.h
2.重新编译
cd /usr/local/src/nginx-1.24.0
./configure --prefix=/apps/nginx --user=nginx --group=nginx --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_stub_status_module --with-http_gzip_static_module --with-pcre --with-stream --with-stream_ssl_module --with-stream_realip_module
//需要注意的是,第二次编译和上一次编译参数一定要保持一致,否则会覆盖掉之前安装的模块。
make -j 2 && make install
3.重启服务生效
systemctl restart nginx
4.测试访问
curl -I www.andy.com
验证成功!
做过上一个实验的记得把隐藏版本号的参数打开。
写在最后的一个神J操作!
还是修改版本号,不过会和之前的修改版本号有所区别,接着往下看。
第一步 隐藏版本号
vim /apps/nginx/conf/nginx.conf
第二步 修改模块文件的版本信息
vim /usr/local/src/nginx-1.24.0/src/http/ngx_http_header_filter_module.c
第三步 重新编译
cd /usr/local/src/nginx-1.24.0
./configure --prefix=/apps/nginx --user=nginx --group=nginx --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_stub_status_module --with-http_gzip_static_module --with-pcre --with-stream --with-stream_ssl_module --with-stream_realip_module
make -j 2 && make install
第四步 重启服务,让主进程重新读取配置并应用
systemctl restart nginx
第五步 验证版本
curl -I www.andy.com
Apache服务器验证成功!!!
我又出现在你面前,你看我有几分像从前【手动狗头】