大家好,我是早九晚十二,目前是做運維相關(guān)的工作。寫博客是為了積累,希望大家一起進(jìn)步!
我的主頁:早九晚十二
最近,nginx曝出了最新漏洞CVE-2022-41741,這個影響還是比較大的,因為這個包含了一些相對穩(wěn)定的版本,所以好多環(huán)境都需要有升級。
那么,如何快速的升級nginx版本,規(guī)避這些漏洞呢?
版本選擇
升級我們選擇1.23.4版本,下載地址:https://nginx.org/download/nginx-1.23.4.tar.gz
[root@localhost]# tar xf nginx-1.23.4.tar.gz
[root@localhost ~]# cd nginx-1.23.4
[root@localhost nginx-1.23.4]# ls
auto CHANGES CHANGES.ru conf configure contrib html LICENSE man README src
編譯服務(wù)
[root@localhost nginx-1.23.4]# ./configure --prefix=/usr/local/nginx --with-http_ssl_module
checking for OS
+ Linux 3.10.0-1160.el7.x86_64 x86_64
checking for C compiler ... not found
./configure: error: C compiler cc is not found
##錯誤解決
yum -y install gcc gcc-c++ autoconf automake make
##再次執(zhí)行編譯命令
[root@localhost nginx-1.23.4] ./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-openssl=system
./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.
##問題解決
yum install -y pcre pcre-devel zlib zlib-devel
##安裝nginx
make
這時候會報錯openssl的問題,我們需先安裝openssl
[root@localhost]# wget -k https://www.openssl.org/source/openssl-1.1.1t.tar.gz --no-check-certificate
[root@localhost]# tar zxf openssl-1.1.1t.tar.gz
[root@localhost]# cd openssl-1.1.1t
[root@localhost]# ./config
注意不能再共享目錄make校驗
[root@localhost]# make clean && make
#安裝
[root@localhost]# make install
##配置默認(rèn)openssl路徑
echo "/usr/local/lib64/" >> /etc/ld.so.conf
ldconfig
修改openssl配置
打開nginx原文件下conf文件文章來源:http://www.zghlxwxcb.cn/news/detail-475430.html
#如果編譯的openssl沒有在默認(rèn)目錄下,需要修改nginx源文件的配置,改成對應(yīng)的openssl路徑
[root@localhost]# vim nginx-1.23.4/auto/lib/openssl/conf
#修改39-42行
39 CORE_INCS="$CORE_INCS $OPENSSL/.openssl/include"
40 CORE_DEPS="$CORE_DEPS $OPENSSL/.openssl/include/openssl/ssl.h"
41 CORE_LIBS="$CORE_LIBS $OPENSSL/.openssl/lib/libssl.a"
42 CORE_LIBS="$CORE_LIBS $OPENSSL/.openssl/lib/libcrypto.a"
再次編譯
[root@localhost nginx-1.23.4]# make && make install
|| cp conf/uwsgi_params '/usr/local/nginx/conf'
cp conf/uwsgi_params \
'/usr/local/nginx/conf/uwsgi_params.default'
test -f '/usr/local/nginx/conf/scgi_params' \
|| cp conf/scgi_params '/usr/local/nginx/conf'
cp conf/scgi_params \
'/usr/local/nginx/conf/scgi_params.default'
test -f '/usr/local/nginx/conf/nginx.conf' \
|| cp conf/nginx.conf '/usr/local/nginx/conf/nginx.conf'
cp conf/nginx.conf '/usr/local/nginx/conf/nginx.conf.default'
test -d '/usr/local/nginx/logs' \
|| mkdir -p '/usr/local/nginx/logs'
test -d '/usr/local/nginx/logs' \
|| mkdir -p '/usr/local/nginx/logs'
test -d '/usr/local/nginx/html' \
|| cp -R html '/usr/local/nginx'
test -d '/usr/local/nginx/logs' \
|| mkdir -p '/usr/local/nginx/logs'
make[1]: Leaving directory `/root/nginx-1.23.4'
檢查nginx版本
[root@localhost3 nginx-1.23.4]# /usr/local/nginx/sbin/nginx -v
nginx version: nginx/1.23.4
碼字不易。如果文章對您有希望的話,請三連支持一波。
如有問題,歡迎留言,一起探討,感謝。
也可關(guān)注下方公眾號,看到留言后會第一時間回復(fù)。文章來源地址http://www.zghlxwxcb.cn/news/detail-475430.html
到了這里,關(guān)于nginx(CVE-2022-41741)漏洞修復(fù)的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!