nginx升级之openssl 漏洞

环境

1 之前是yum 安装的
2 centos 6.5

步骤

  • 升级openssl
  • 升级nginx

升级openssl

为了修补openssl低版本存在的漏洞,现将Centos 6.5系统openssl版本1.0.1e升级到1.1.0i(系统6.5-6.9都适用),升级包括下载openssl-1.1.0i.tar.gz以及基础环境否则在"make"这一步会报错,故一定要安装zlib和zlib-devel
[root@ndsc ~]# yum -y install zlib zlib-devel
  646  wget https://www.openssl.org/source/openssl-1.1.1g.tar.gz
  647  ll
  648  tar zxvf openssl-1.1.1g.tar.gz 
  649  cd openssl-1.1.1g
  650  ./config shared zlib
  651  make
  652  ll
  653  make install
  654  mv /usr/bin/openssl /usr/bin/openssl.bak
  655  find / -name openssl
  656  cat /etc/ld.so.conf
  657  echo "/usr/local/lib64/" >> /etc/ld.so.conf
  658  cat /etc/ld.so.conf
  659  ldconfig -v
  660  openssl version


Centos 6.5系统openssl版本升级

升级nginx
如果openssl 是静态编译的,直接将openssl 编译到nginx里面去了,这就意味着,单纯升级openssl 是没有任何效果的,nginx不会加载外部的openssl动态链接库的,必须将nginx重新编译。
nginx –V

如果编译参数中含有 –with-openssl= path ,或者有 –with-http_ssl_module ,则表明nginx 是静态编译的,那么恭喜你在升级完openssl 之后还有重新编译nginx,指定openssl 的目录。

# nginx -V

built with OpenSSL 1.0.1e-fips 11 Feb 2013

看到之前用的是openssl1.0.1需要升级
下载和之前一样的nginx版本
wget http://nginx.org/download/nginx-1.10.3.tar.gz
  683  tar zxvf nginx-1.10.3.tar.gz 
  684  ll
  685  cd nginx-1.10.3
  686  ll
  687  which nginx
  688  ll /usr/sbin/nginx 
  689  nginx -V
看看之前的编译参数
  备份一下之前的nginx程序
  694  cp /usr/sbin/nginx /usr/sbin/nginxbak

按原来的重新编译
./configure --prefix=/usr/share/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/lib/nginx/tmp/client_body --http-proxy-temp-path=/var/lib/nginx/tmp/proxy --http-fastcgi-temp-path=/var/lib/nginx/tmp/fastcgi --http-uwsgi-temp-path=/var/lib/nginx/tmp/uwsgi --http-scgi-temp-path=/var/lib/nginx/tmp/scgi --pid-path=/var/run/nginx.pid --lock-path=/var/lock/subsys/nginx --user=nginx --group=nginx --with-file-aio --with-ipv6 --with-http_ssl_module --with-openssl --with-http_v2_module --with-http_realip_module --with-http_addition_module --with-http_xslt_module=dynamic --with-http_image_filter_module=dynamic --with-http_geoip_module=dynamic --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_degradation_module --with-http_slice_module --with-http_stub_status_module --with-http_perl_module=dynamic --with-pcre --with-pcre-jit --with-stream=dynamic --with-stream_ssl_module --with-debug --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic' --with-ld-opt=' -Wl,-E'


编译时可能出现问题,百度一下安装下缺少的包就行
然后编译成功后注意千万不要make install
只要make 一下就行
然后把objs下的nginx复制到/usr/sbin,还有so文件替换一下 /usr/lib64/nginx/modules这里面的

 cd /usr/lib64/nginx/
  787  ll
  788  cd modules/
  789  ll
  790  cd ..
  791  cp -rp modules modulesbak
  792  cd modules
  793  cp -rp /opt/nginx-1.10.3/objs/*so .
最后停原来的nginx,启动新nginx

验证

python test.py xxxxx     
Connecting...
Sending Client Hello...
Waiting for Server Hello...
 ... received message: type = 22, ver = 0302, length = 61
 ... received message: type = 22, ver = 0302, length = 1725
 ... received message: type = 22, ver = 0302, length = 331
 ... received message: type = 22, ver = 0302, length = 4
Sending heartbeat request...
 ... received message: type = 21, ver = 0302, length = 2
Received alert:
  0000: 02 0A                                            ..

Server returned error, likely not vulnerable

看到likely not vulnerable,搞定了。

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

友情链接更多精彩内容