nginx(CVE-2022-41741)漏洞修复

大家好,我是早九晚十二,目前是做运维相关的工作。写博客是为了积累,希望大家一起进步!
我的主页:早九晚十二

最近,nginx曝出了最新漏洞CVE-2022-41741,这个影响还是比较大的,因为这个包含了一些相对稳定的版本,所以好多环境都需要有升级。
在这里插入图片描述
那么,如何快速的升级nginx版本,规避这些漏洞呢?

版本选择

升级我们选择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

编译服务

[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

##再次执行编译命令
[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

##配置默认openssl路径
echo "/usr/local/lib64/" >> /etc/ld.so.conf
ldconfig

修改openssl配置

打开nginx原文件下conf文件

#如果编译的openssl没有在默认目录下,需要修改nginx源文件的配置,改成对应的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

码字不易。如果文章对您有希望的话,请三连支持一波。
如有问题,欢迎留言,一起探讨,感谢。
也可关注下方公众号,看到留言后会第一时间回复。

  • 6
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 7
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 7
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

早九晚十二

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值