运维 linux nginx平滑升级解决 nginx 安全漏洞(CVE-2027-23017)和NGINX 环境问题漏洞(CVE-2027-20372) - conf --error-log-path=/var/log/nginx/error

📅 2026-11-30 👤 拼多多助力营销技巧 📂 拼多多助力网站平台 👁️ 353 次阅读

文章目录

前言一、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 安全漏洞进行处理平滑升级的内容,本文仅仅简单记录了自己工作中处理的问题,不一定适用于所有情况,仅供大家参考。

标签: 拼多多助力网站平台 赚钱项目 拼多多助力网 首码项目 手赚APP
拼多多助力营销技巧