网上看到这篇文章,这里记录一下。
前言
前段时间我们官网要做一个活动页面, 但是活动页面是用另一个活动页域名, activity.example.com, 但是运营人员需要对外展示的落地页是以官网 www 的域名来处理,所以这时候就会需要在官网的 nginx 指向那边进行页面的代理转发:
1 2 3 4 |
location /promo/student-discount { resolver 8.8.8.8; proxy_pass https://activity.example.com/promo/student-discount; } |
但是实测的过程中, 却发现代理转发的时候,报了一个 502 的错误
1 2 |
2022/08/16 11:58:22 [error] 2293#0: *213338285 SSL_do_handshake() failed (SSL: error:1408F10B:SSL routines:ssl3_get_record:wrong version number) while SSL handshaking to upstream, client: 14.xxx.1.86, server: www.example.com, request: "HEAD /promo/student-discount HTTP/1.1", upstream: "https://13.xxx.xxx.101:443/promo/student-discount", host: "www.example.com" 2022/08/16 11:58:22 [warn] 2293#0: *213338285 upstream server temporarily disabled while SSL handshaking to upstream, client: 14.xxx.1.86, server: www.example.com, request: "HEAD /promo/student-discount HTTP/1.1", upstream: "https://13.xxx.125.101:443/promo/student-discount", host: "www.example.com" |
看了一下,应该是 nginx 在进行代理请求的时候,就报错了, 应该是 ssl 的握手的错误 SSL_do_handshake()
SNI介绍
SNI(Server Name Indication)是为了解决一个服务器使用 多个域名 和证书的TLS扩展,主要解决一台服务器只能使用一个证书的缺点。
开启SNI后,允许客户端在发起SSL握手请求时就提交请求的域名信息, 负载均衡 收到SSL请求后,会根据域名去查找证书,如果找到域名对应的证书,则返回该证书;如果没