修复方式:改变HTTP服务器的缺省 banner
nginx修复:
下载 Nginx 扩展 headers-more-nginx-module
wget https://github.com/openresty/headers-more-nginx-module/archive/v0.34.tar.gz
解压: tar -zxvf v0.34.tar.gz
进入到 Nginx 的安装目录 执行 nginx -V 查看安装参数,拷贝 configure arguments 后的安装参数
在安装目录下执行./configure 粘贴的内容 --add-module=headers-more-nginx-module的路径,建议 headers-more-nginx-module也放在nginx安装目录下(如图)
执行
make #不要 make install
然后把编译过的nginx执行文件复制到原先的nginx安装目录下
执行完以上操作就可以到 Nginx.conf 的 http 中添加 more_clear_headers ‘Server’;
具体操作:
linux服务器上执行wget下载扩展包(也可以本地下载好上传到服务器):
wget https://github.com/openresty/headers-more-nginx-module/archive/v0.34.tar.gz
tar -zxvf v0.34.tar.gz
解压后的目录名为headers-more-nginx-module-0.34,建议直接放到nginx安装目录
进入nginx源码包编译,原有的编译后加上 --add-module=headers-more-nginx-module-0.34 (解压路径)
XX/nginx/sbin/nginx -V 查看nginx版本及原来的编译方法
进入nginx源码包 编译
cd /usr/local/nginx-1.25.1
./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-http_v2_module --with-stream --add-module=headers-more-nginx-module-0.34
make
(不要进行make install,否则就是覆盖安装)
备份原有已安装好的nginx
cp /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.bak
将刚刚编译好的nginx覆盖掉原有的nginx(这个时候nginx要停止状态)
cp ./objs/nginx /usr/local/nginx/sbin/
注:编译后的nginx在源码(安装目录中)objs路径下
修改nginx配置文件/usr/local/nginx/conf/nginx.conf
Nginx.conf 的 http 中添加 下面一行
more_clear_headers 'Server';
查看nginx版本,看是否已经加入成功
/usr/local/nginx/sbin/nginx -V
启动nginx:
cd /usr/local/nginx/sbin
./nginx