Nginx与OpenSSL平滑升级,解决部分网站Firefox可以正常访问,但Chrome访问提示“此网站无法提供安全连接,ERR SSL PROTOCOL ERROR”

一、安装包的下载

(1)Nginx的下载(这里下载最新的稳定版本1.26.1):下载地址nginx: downloadicon-default.png?t=N7T8https://nginx.org/en/download.html

(2)Pcre的下载(这里选择稳定版本8.41): PCRE download | SourceForge.netDownload PCRE for free. PERL 5 regular expression pattern matching. The Perl Compatible Regular Expressions (PCRE) library is a set of functions that implement regular expression pattern matching using the same syntax and semantics as Perl 5. PCRE has its own native API, in addition to a set of POSIX compatible wrapper functions.icon-default.png?t=N7T8https://sourceforge.net/projects/pcre/,这个是nginx编译安装的依赖包

(3)OpenSSL的下载(这里选择下载最新稳定版本3.3.1):[ Downloads ] - /source/index.htmlicon-default.png?t=N7T8https://www.openssl.org/source/,主要解决谷歌新版浏览器访问提示“ERR SSL PROTOCOL ERROR”的问题

二、OpenSSL的安装

(1)查看OpenSSL的版本

(2)查看OpenSSL的路径

https://img-blog.csdnimg.cn/direct/3919212b5395484c8c61c3e1f8e40e55.png

(3)备份OpenSSL文件

sudo mv /usr/bin/openssl /usr/bin/openssl_old

sudo mv /usr/include/openssl /usr/include/openssl_old

(4)解压OpenSSL并配置安装目录

tar –zxvf openssl-3.3.1.tar.gz

(5)切换到解压好的openssl目录

cd openssl-3.3.1/

(6)配置openssl安装目录

./config --prefix=/usr/local/openssl

https://img-blog.csdnimg.cn/direct/e2433db173f54beeafd8e5e553595a6a.png

(7)编译与安装

sudo make && sudo make install

等待完成即可

(8)创建软链接

说明:创建的软链接和之前没升级通过whereis openssl保持一致即可。

ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl

ln -s /usr/local/openssl/include/openssl /usr/include/openssl

(9)添加动态链接库数据(注意需要切到root用户才有权限)

echo "/usr/local/openssl/lib64/" >> /etc/ld.so.conf

检查一下,已经在/etc/ld.so.conf中存在:

include ld.so.conf.d/*.conf

/usr/local/openssl/lib64/

(10)更新动态链接库:

sudo ldconfig -v

(11)验证openssl

查看openssl版本 openssl version -a会显示全面详细信息

OpenSSL 3.3.1 4 Jun 2024 (Library: OpenSSL 3.3.1 4 Jun 2024)

built on: Thu Jun 13 02:55:45 2024 UTC

platform: linux-x86_64

options:  bn(64,64)

compiler: gcc -fPIC -pthread -m64 -Wa,--noexecstack -Wall -O3 -DOPENSSL_USE_NODELETE -DL_ENDIAN -DOPENSSL_PIC -DOPENSSL_BUILDING_OPENSSL -DNDEBUG

OPENSSLDIR: "/usr/local/openssl/ssl"

ENGINESDIR: "/usr/local/openssl/lib64/engines-3"

MODULESDIR: "/usr/local/openssl/lib64/ossl-modules"

Seeding source: os-specific

CPUINFO: OPENSSL_ia32cap=0xfefa320b5f8bffff:0x800d19e4fbb

(12)到此openssl升级完成

三、Nginx新版本的安装

(1)将下载的好Nginx-1.26.1解压并进入Nginx-1.26.1目录

tar -zxvf Ninx-1.26.1.gz

cd /opt/Nginx-1.26.1/

(2)查看旧版本Nginx配置的编译文件并复制configure arguments,将openssl对应的版本替换一下

nginx version: nginx/1.11.3

built by gcc 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.9)

built with OpenSSL 1.0.1 14 Mar 2012

TLS SNI support enabled

configure arguments: --prefix=/usr/local/nginx --with-http_ssl_module --with-http_flv_module --with-http_stub_status_module --with-http_gzip_static_module --with-pcre=../pcre-8.41 --with-openssl=../openssl-1.0.1

(3)配置Nginx新版本的编译参数

[root@web03 nginx-1.24.0]# ./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-http_flv_module --with-http_stub_status_module --with-http_gzip_static_module --with-pcre=../pcre-8.41 --with-openssl=../openssl-3.3.1

(4)执行make,不要make install

[root@web03 nginx-1.24.0]# sudo make

(5)将nginx-1.26.0目录下的nginx放到/usr/local/nginx/sbin/目录下

[root@web03 sbin]# mv /opt/nginx-1.26.0/objs/nginx /usr/local/nginx/sbin/

[root@web03 sbin]# ls

nginx

[root@web03 sbin]#

(6)生成新的nginx  master进程

[root@web03 ~]# cd /usr/local/nginx/logs/

[root@web03 logs]# cat nginx.pid

15210

[root@web03 logs]# kill -USR2 15210

[root@web03 logs]# ls

access.log  error.log  nginx.pid  nginx.pid.oldbin

[root@web03 logs]#

可以看到,当前的nginx进程文件自动命名为nginx.pid.oldbin,又生成了一个新的nginx.pid文件

(7)生成新的nginx  master进程

[root@web03 logs]# cat nginx.pid.oldbin

15210

[root@web03 logs]# kill -WINCH 15210

[root@web03 logs]# kill -QUIT 15210

[root@web03 logs]# ls

access.log  error.log  nginx.pid

[root@web03 logs]#

旧版本的nginx进程已经被新版本的nginx进程替代

(8)可以看到当前版本已经升级到了1.26.1

[root@web03 logs]# /usr/local/nginx/sbin/nginx -V

nginx version: nginx/1.26.1

built by gcc 7.4.0 (Ubuntu 7.4.0-1ubuntu1~18.04.1)

built with OpenSSL 3.3.1 4 Jun 2024

TLS SNI support enabled

configure arguments: --prefix=/usr/local/nginx --with-http_ssl_module --with-http_flv_module --with-http_stub_status_module --with-http_gzip_static_module --with-pcre=../pcre-8.41 --with-openssl=../openssl-3.3.1

(9)访问页面测试:输入网站即可

  • 11
    点赞
  • 21
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
解决nginx配置无法网站建立全连接的问题,可以采取以下几个步骤: 1. 检查SSL证书:确保所使用的SSL证书是有效的,并且正确地装在服务器上。可以使用SSL证书验证工具来检查证书的有效性。 2. 检查配置文件:确保nginx配置文件中的SSL相关项正确配置。例如,检查是否正确指定了SSL证书的路径和私钥的路径,并且确保SSL监听端口正确设置。 3. 检查防火墙设置:检查服务器上的防火墙设置,确保允许通过SSL监听端口进行访问。如果防火墙设置不正确,可能会导致无法建立全连接。 4. 更新openssl库:如果nginx使用的openssl库版本过旧,可能会导致无法建立全连接。可以尝试更新openssl库到最新版本,然后重新编译nginx。 5. 检查域名解析:如果使用了自定义域名,确保域名解析正确,指向了正确的服务器IP地址。可以通过ping命令或域名解析工具来验证域名解析是否正确。 6. 检查其他软件配置:如果服务器上还装了其他软件,如反向代理服务器,确保它们的配置与nginxSSL配置相兼容。有时候,其他软件的配置可能会导致全连接无法建立。 7. 查看日志文件:查看nginx的错误日志文件,通常位于/var/log/nginx/error.log,查找有关SSL连接错误的相关信息,以便进一步排查问题。 如果以上步骤都正确配置,并且问题仍然存在,可以尝试在论坛或在线技术社区上寻求帮助,以获取更详细的指导。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值