栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

nginx平滑升级解决 nginx 安全漏洞(CVE-2021-23017)和NGINX 环境问题漏洞(CVE-2019-20372)

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

nginx平滑升级解决 nginx 安全漏洞(CVE-2021-23017)和NGINX 环境问题漏洞(CVE-2019-20372)

文章目录
  • 前言
  • 一、linux下载
  • 二、平滑升级
    • 1.查看nginx版本
    • 2.nginx上传解压,文件替换
    • 3.查看升级是否成功
  • 总结


前言

关于漏洞扫描nginx安全漏洞的修复。
服务器漏洞扫描中扫出了nginx的安全漏洞,nginx 安全漏洞(CVE-2021-23017)和NGINX 环境问题漏洞(CVE-2019-20372),受影响版本为0.6.18-1.20.0;给出解决办法为升级补丁修复,由于漏洞较多考虑平滑升级。


提示:以下是本篇文章正文内容,下面案例可供参考

一、linux下载

官方下载渠道下载1.20.0以上版本的linux。下载地址:
http://nginx.org/en/download.html

我使用的服务器是linux系统,推荐下载官网Stable version的1.22.0版本。

二、平滑升级 1.查看nginx版本

代码如下(示例):

查看nginx进程
ps -ef | grep nginx


找到Nginx 二进制可执行文件后,查看nginx版本,可以看到当前版本为1.18.0:

/usr/sbin/nginx -V
nginx version: nginx/1.18.0
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-39) (GCC) 
built with OpenSSL 1.0.2k-fips  26 Jan 2017
TLS SNI support enabled
configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -fPIC' --with-ld-opt='-Wl,-z,relro -Wl,-z,now -pie'


将Nginx 二进制可执行文件先备份,出错了好回退。

mv /usr/sbin/nginx /usr/sbin/nginx-1.18
2.nginx上传解压,文件替换

将下载的压缩包上传至linux服务器,上传位置没有要求,我这里上传解压到了旧版linux的同级目录:

解压压缩文件

[root@i]# cd etc/
[root@i etc]# tar xf nginx-1.22.0.tar.gz

进入解压后的文件夹内,使用configure 进行配置,configure 后跟的参数是第一步复制的,由于上个版本部署的nginx改了配置文件及日志的位置,此命令仅供参考,路径由实际情况自行修改:

[root@i etc]# cd nginx-1.22.0
[root@i nginx-1.22.0]# ./configure --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -fPIC' --with-ld-opt='-Wl,-z,relro -Wl,-z,now -pie'

简单配置的话可适用此命令:

[root@i nginx-1.22.0]# ./configure --prefix=/etc/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_v2_module

上一步完成后make:

[root@i nginx-1.22.0]# make

此时配置完成,将新的Nginx 二进制可执行文件,放到原来的目录下,注意1.22.0版本的nginx文件在objs目录下,不在sbin目录里:

[root@i nginx-1.22.0]# cp objs/nginx /usr/sbin/nginx
3.查看升级是否成功

出现test is successful说明nginx正常运行:

[root@i nginx-1.22.0]# /usr/sbin/nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

查看版本是否升级成功,可以看到版本已升级至1.22.0

[root@i nginx-1.22.0]# /usr/sbin/nginx -V
nginx version: nginx/1.22.0
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-28) (GCC) 
built with OpenSSL 1.0.2k-fips  26 Jan 2017
TLS SNI support enabled
configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -fPIC' --with-ld-opt='-Wl,-z,relro -Wl,-z,now -pie'

总结

以上就是对nginx 安全漏洞进行处理平滑升级的内容,本文仅仅简单记录了自己工作中处理的问题,不一定适用于所有情况,仅供大家参考。

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/972325.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号