• 设为首页
  • 收藏本站
  • 积分充值
  • VIP赞助
  • 手机版
  • 微博
  • 微信
    微信公众号 添加方式:
    1:搜索微信号(888888
    2:扫描左侧二维码
  • 快捷导航
    福建二哥 门户 查看主题

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

    发布者: 娅水9213 | 发布时间: 2025-8-16 14:56| 查看数: 66| 评论数: 0|帖子模式

    前言

    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版本信息
    1. [root@web ~]# /usr/local/nginx/sbin/nginx -V
    2. nginx version: nginx/1.12.2
    3. built by gcc 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC)
    4. 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/下,解压并进入解压后的目录
    1. [root@nginx ~]# cd /usr/local/
    2. [root@nginx ~]# wget http://nginx.org/download/nginx-1.21.5.tar.gz
    3. [root@nginx ~]# tar xf nginx-1.21.5.tar.gz
    4. [root@nginx ~]# cd nginx-1.21.5
    复制代码
    3.配置nginx

    查看nginx版本的时候,configure arguments后面有一大串模块,这也是你第一次安装nginx时所指定的模块,升级的时候也要同时指定,也可以添加其他模块
    1. [root@nginx nginx-1.21.5]# ./configure \
    2.   --prefix=/usr/local/nginx \
    3.   --user=nginx \
    4.   --group=nginx \
    5.   --with-pcre \
    6.   --with-openssl=/tmp/openssl-1.1.0e \
    7.   --with-http_ssl_module \
    8.   --with-http_v2_module \
    9.   --with-http_realip_module \
    10.   --with-http_addition_module \
    11.   --with-http_sub_module \
    12.   --with-http_dav_module \
    13.   --with-http_flv_module \
    14.   --with-http_mp4_module \
    15.   --with-http_gunzip_module \
    16.   --with-http_gzip_static_module \
    17.   --with-http_random_index_module \
    18.   --with-http_secure_link_module \
    19.   --with-http_stub_status_module \
    20.   --with-http_auth_request_module \
    21.   --with-http_image_filter_module \
    22.   --with-mail \
    23.   --with-threads \
    24.   --with-mail_ssl_module \
    25.   --with-stream_ssl_module \
    26. && make
    复制代码
    make完以后,不需要执行make install,否则会覆盖安装,nginx服务会出现各种问题
    不中断nginx web服务器的正常运行称之为平滑升级,先重命名之前的nginx二进制文件
    1. [root@nginx nginx-1.21.5]# mv /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.bak
    复制代码
    拷贝刚编译新生产的Nginx二进制文件到/usr/local/nginx/sbin/目录
    1. [root@nginx nginx-1.21.5]# cp /usr/local/nginx-1.21.5/objs/nginx /usr/local/nginx/sbin/
    复制代码
    4.开始执行升级
    1. [root@web nginx-1.21.5]# make upgrade
    2. /usr/local/nginx/sbin/nginx -t
    3. nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
    4. nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
    5. kill -USR2 `cat /usr/local/nginx/logs/nginx.pid`
    6. sleep 1
    7. test -f /usr/local/nginx/logs/nginx.pid.oldbin
    8. kill -QUIT `cat /usr/local/nginx/logs/nginx.pid.oldbin`
    复制代码
    5.查看nginx版本信息
    1. [root@web nginx-1.13.3]# /usr/local/nginx/sbin/nginx -V
    2. nginx version: nginx/1.21.5
    3. built by gcc 4.8.5 20150623 (Red Hat 4.8.5-28) (GCC)
    4. built with OpenSSL 1.1.0e  16 Feb 2017
    5. TLS SNI support enabled
    6. 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 平滑升级内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!

    来源:互联网
    免责声明:如果侵犯了您的权益,请联系站长(1277306191@qq.com),我们会及时删除侵权内容,谢谢合作!

    最新评论

    QQ Archiver 手机版 小黑屋 福建二哥 ( 闽ICP备2022004717号|闽公网安备35052402000345号 )

    Powered by Discuz! X3.5 © 2001-2023

    快速回复 返回顶部 返回列表