Nginx 平滑升级的实现(拒绝服务漏洞)

 更新时间:2025年02月21日 08:32:34   作者:Mr-Wanter  
本文主要介绍了Nginx 平滑升级的实现(拒绝服务漏洞),文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧

前言

Nginx 拒绝服务漏洞(CVE-2019-9513、CVE-2019-9511)

  • 将 Nginx 升级到 1.16.1、1.17.3 及以上版本,下载地址:https://nginx.org/en/download.html
  • 若漏洞的检测结果中存在漏洞修复版本,则将漏洞检测结果中的软件包升级到对应漏洞修复版本及以上。
    参照安全补丁功能中该漏洞的修复命令进行升级,或者参照以下修复命令进行升级:
    CentOS/RHEL/Oracle Linux : sudo yum update -y 需要升级的软件包名(参考检测结果)
    SUSE : sudo zypper update -y 需要升级的软件包名(参考检测结果)
    Ubuntu/Debian : sudo apt-get update && sudo apt-get install --only-upgrade -y 需要升级的软件包名(参考检测结果)
    例:若漏洞的检测结果中主机系统为 Ubuntu 16.04,软件包名称为 nginx,当前安装版本为 1.10.3-0ubuntu0.16.04.4,对应漏洞修复版本为1.10.3-0ubuntu0.16.04.5,则漏洞修复命令为 sudo apt-get update && sudo apt-get install --only-upgrade -y nginx-core nginx

一、CentOS 7 Nginx1.12.2平滑升级到新版本nginx-1.21.5

nginx下载:http://nginx.org/download/

二、操作步骤

1.查看当前Nginx版本信息

[root@web ~]# /usr/local/nginx/sbin/nginx -V
nginx version: nginx/1.12.2
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC)
configure arguments: --prefix=/usr/local/nginx --user=nginx --group=nginx --with-pcre --with-openssl=/tmp/openssl-1.1.0e --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-http_auth_request_module --with-http_image_filter_module --with-mail --with-threads --with-mail_ssl_module --with-stream_ssl_module

2.下载nginx-1.21.5版本到/usr/local/下,解压并进入解压后的目录

[root@nginx ~]# cd /usr/local/
[root@nginx ~]# wget http://nginx.org/download/nginx-1.21.5.tar.gz
[root@nginx ~]# tar xf nginx-1.21.5.tar.gz
[root@nginx ~]# cd nginx-1.21.5

3.配置nginx

查看nginx版本的时候,configure arguments后面有一大串模块,这也是你第一次安装nginx时所指定的模块,升级的时候也要同时指定,也可以添加其他模块

[root@nginx nginx-1.21.5]# ./configure \
  --prefix=/usr/local/nginx \
  --user=nginx \
  --group=nginx \
  --with-pcre \
  --with-openssl=/tmp/openssl-1.1.0e \
  --with-http_ssl_module \
  --with-http_v2_module \
  --with-http_realip_module \
  --with-http_addition_module \
  --with-http_sub_module \
  --with-http_dav_module \
  --with-http_flv_module \
  --with-http_mp4_module \
  --with-http_gunzip_module \
  --with-http_gzip_static_module \
  --with-http_random_index_module \
  --with-http_secure_link_module \
  --with-http_stub_status_module \
  --with-http_auth_request_module \
  --with-http_image_filter_module \
  --with-mail \
  --with-threads \
  --with-mail_ssl_module \
  --with-stream_ssl_module \
 && make

make完以后,不需要执行make install,否则会覆盖安装,nginx服务会出现各种问题

不中断nginx web服务器的正常运行称之为平滑升级,先重命名之前的nginx二进制文件

[root@nginx nginx-1.21.5]# mv /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.bak

拷贝刚编译新生产的Nginx二进制文件到/usr/local/nginx/sbin/目录

[root@nginx nginx-1.21.5]# cp /usr/local/nginx-1.21.5/objs/nginx /usr/local/nginx/sbin/

4.开始执行升级

[root@web nginx-1.21.5]# make upgrade
/usr/local/nginx/sbin/nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
kill -USR2 `cat /usr/local/nginx/logs/nginx.pid`
sleep 1
test -f /usr/local/nginx/logs/nginx.pid.oldbin
kill -QUIT `cat /usr/local/nginx/logs/nginx.pid.oldbin`

5.查看nginx版本信息

[root@web nginx-1.13.3]# /usr/local/nginx/sbin/nginx -V
nginx version: nginx/1.21.5
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-28) (GCC)
built with OpenSSL 1.1.0e  16 Feb 2017
TLS SNI support enabled
configure arguments: --prefix=/usr/local/nginx --user=nginx --group=nginx --with-pcre --with-openssl=/tmp/openssl-1.1.0e --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-http_auth_request_module --with-http_image_filter_module --with-mail --with-threads --with-mail_ssl_module --with-stream_ssl_module

总结

报错0

nginx unknown directive “stream”

nginx默认安装的时候没有加载stream模块

需要重新对源文件进行编译、安装,通过添加–with-stream参数指定安装stream模块

./configure --with-stream

make & make install

再次检查nginx.conf配置文件,确认配置无语法错误后,再次尝试启动服务。

nginx -t 检查配置文件是否正确

nginx -c 指定启动的配置文件

报错1

./configure: error: the HTTP XSLT module requires the libxml2/libxslt
libraries. You can either do not enable the module or install the libraries.
原因:缺少依赖
解决:
[root@vm-3 nginx-1.21.5]# yum -y install libxml2 libxslt-devel

再次配置

报错2

./configure: error: the HTTP image filter module requires the GD library.
You can either do not enable the module or install the libraries.
解决:安装依赖
yum -y install gd-devel

再次配置

报错3

./configure: error: perl module ExtUtils::Embed is required
解决:
yum -y install perl-devel perl-ExtUtils-Embed
再次配置

报错4

./configure: error: the GeoIP module requires the GeoIP library. You can either do not enable the module or install the library.
解决:
yum -y install GeoIP GeoIP-devel GeoIP-data
再次配置

报错5

./configure: error: the Google perftools module requires the Google perftools
library. You can either do not enable the module or install the library.

到此这篇关于Nginx 平滑升级的实现(拒绝服务漏洞)的文章就介绍到这了,更多相关Nginx 平滑升级内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!

相关文章

  • 解析nginx server_name的具体使用

    解析nginx server_name的具体使用

    nginx server_name对于正确配置虚拟主机非常重要,本文主要介绍了解析nginx server_name的具体使用,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
    2023-08-08
  • Nginx 虚拟主机配置的三种方式(基于域名)

    Nginx 虚拟主机配置的三种方式(基于域名)

    Nginx配置虚拟主机支持3种方式:基于IP的虚拟主机配置,基于端口的虚拟主机配置,基于域名的虚拟主机配置。本文主要介绍了基于域名的实现,感兴趣的小伙伴们可以参考一下
    2018-10-10
  • Nginx中default_server指令问题详解

    Nginx中default_server指令问题详解

    nginx 的 default_server 指令可以定义默认的 server 出处理一些没有成功匹配 server_name 的请求,下面这篇文章主要给大家介绍了关于Nginx中default_server指令问题的相关资料,需要的朋友可以参考下
    2022-12-12
  • Nginx配置WSS安全WebSocket代理的实现

    Nginx配置WSS安全WebSocket代理的实现

    本文详细介绍Nginx配置WSS(WebSocket安全连接)的方法,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
    2025-12-12
  • 讲解Nginx服务器中设置本地浏览器缓存的简单方法

    讲解Nginx服务器中设置本地浏览器缓存的简单方法

    这篇文章主要介绍了Nginx服务器中设置本地浏览器缓存的简单方法,需要的朋友可以参考下
    2015-12-12
  • Nginx可视化nginxWebUI的具体使用

    Nginx可视化nginxWebUI的具体使用

    NginxWebUI 是一款图形化管理 nginx 配置的工具,可以使用网页来快速配置 nginx单机与集群的各项功能,本文就来介绍一下Nginx网页配置工具nginxWebUI的具体使用,感兴趣的可以了解一下
    2023-08-08
  • Nginx日志配置的使用及说明

    Nginx日志配置的使用及说明

    这篇文章主要介绍了Nginx日志配置的使用及说明,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教
    2025-07-07
  • 一文搞懂Nginx限流(简单实现)

    一文搞懂Nginx限流(简单实现)

    这篇文章主要介绍了一文搞懂Nginx限流(简单实现),小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
    2019-05-05
  • 在Ubuntu20.04上安装Kubernetes集群

    在Ubuntu20.04上安装Kubernetes集群

    容器化为开发人员提供了很大的灵活性,最常用的容器化应用程序之一是 Docker,在容器上部署服务的主要原因之一是它们灵活、轻量级并且在部署在数百台机器上时易于扩展,但是,谁来管理所有这些容器?这就是 Kubernetes 发挥作用的地方
    2023-12-12
  • Windows下用Nginx代理Django安装配置实例

    Windows下用Nginx代理Django安装配置实例

    这篇文章主要介绍了Windows下用Nginx代理Django安装配置实例,本文讲解了安装djanjo、用djanjo生成简单web页面、用nginx进行代理等内容,需要的朋友可以参考下
    2015-03-03

最新评论