Nginx 平滑升級的實現(xiàn)(拒絕服務(wù)漏洞)
前言
Nginx 拒絕服務(wù)漏洞(CVE-2019-9513、CVE-2019-9511)
- 將 Nginx 升級到 1.16.1、1.17.3 及以上版本,下載地址:https://nginx.org/en/download.html
- 若漏洞的檢測結(jié)果中存在漏洞修復(fù)版本,則將漏洞檢測結(jié)果中的軟件包升級到對應(yīng)漏洞修復(fù)版本及以上。
參照安全補(bǔ)丁功能中該漏洞的修復(fù)命令進(jìn)行升級,或者參照以下修復(fù)命令進(jìn)行升級:
CentOS/RHEL/Oracle Linux : sudo yum update -y 需要升級的軟件包名(參考檢測結(jié)果)
SUSE : sudo zypper update -y 需要升級的軟件包名(參考檢測結(jié)果)
Ubuntu/Debian : sudo apt-get update && sudo apt-get install --only-upgrade -y 需要升級的軟件包名(參考檢測結(jié)果)
例:若漏洞的檢測結(jié)果中主機(jī)系統(tǒng)為 Ubuntu 16.04,軟件包名稱為 nginx,當(dāng)前安裝版本為 1.10.3-0ubuntu0.16.04.4,對應(yīng)漏洞修復(fù)版本為1.10.3-0ubuntu0.16.04.5,則漏洞修復(fù)命令為 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.查看當(dāng)前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/下,解壓并進(jìn)入解壓后的目錄
[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完以后,不需要執(zhí)行make install,否則會覆蓋安裝,nginx服務(wù)會出現(xiàn)各種問題
不中斷nginx web服務(wù)器的正常運行稱之為平滑升級,先重命名之前的nginx二進(jìn)制文件
[root@nginx nginx-1.21.5]# mv /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.bak
拷貝剛編譯新生產(chǎn)的Nginx二進(jìn)制文件到/usr/local/nginx/sbin/目錄
[root@nginx nginx-1.21.5]# cp /usr/local/nginx-1.21.5/objs/nginx /usr/local/nginx/sbin/
4.開始執(zhí)行升級
[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
總結(jié)
報錯0
nginx unknown directive “stream”
nginx默認(rèn)安裝的時候沒有加載stream模塊
需要重新對源文件進(jìn)行編譯、安裝,通過添加–with-stream參數(shù)指定安裝stream模塊
./configure --with-stream
make & make install
再次檢查nginx.conf配置文件,確認(rèn)配置無語法錯誤后,再次嘗試啟動服務(wù)。
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.
到此這篇關(guān)于Nginx 平滑升級的實現(xiàn)(拒絕服務(wù)漏洞)的文章就介紹到這了,更多相關(guān)Nginx 平滑升級內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
nginx開啟https配置之后網(wǎng)頁無法訪問的問題處理解決
最近新購服務(wù)器部署nginx之后按照之前的方式部署前端項目并配置https之后訪問頁面無法顯示,本文主要介紹了nginx開啟https配置之后網(wǎng)頁無法訪問的問題處理解決,具有一定的參考價值,感興趣的可以了解一下2023-11-11Nginx配置如何區(qū)分PC或手機(jī)訪問不同域名
這篇文章主要介紹了Nginx配置如何區(qū)分PC或手機(jī)訪問不同域名,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2018-10-10Nginx訪問FTP服務(wù)器文件的時效性/安全校驗的方法
nginx的實現(xiàn)方式在校驗失敗的時候頁面返回error image,跳轉(zhuǎn)的是420 error_page,成功的時候會訪問FTP文件服務(wù)器的路徑,反正圖片到頁面展示,這篇文章主要介紹了Nginx訪問FTP服務(wù)器文件的時效性/安全校驗,需要的朋友可以參考下2023-12-12