https 502 nginx 金山云
今天开发反馈在测试金山云设备的时候遇到了这样的一个现象:
- wget https: //funchlscdn.lechange.cn/LCLR/2K02135PAK01979/0/0/20170726085033/dev_20170726085033_lpxh73ezzb92xxa8.m3u8
- --2017 - 07 - 26 11 : 49 : 26-- https: //funchlscdn.lechange.cn/LCLR/2K02135PAK01979/0/0/20170726085033/dev_20170726085033_lpxh73ezzb92xxa8.m3u8
- Resolving funchlscdn.lechange.cn... 120.92.158.134 Connecting to funchlscdn.lechange.cn | 120.92.158.134 | :443... connected. OpenSSL: error: 140770FC: SSL routines: SSL23_GET_SERVER_HELLO: unknown protocol Unable to establish SSL connection.
爆 "error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol" 的错误,就是在当向只提供 http 的服务发送 https 请求造成的。
#ping funchlscdn.lechange.cn,获得了这个域名对应的 IP 之后,返回到金山云的控制台,发现这个 IP 是一个负载均衡,但是这个负载均衡配置的时候对 80 端口是 http 协议,而对 443 端口还是 http 协议,于是更改成 https,重新测试之后,发现错误变成了这样:
- [[email protected] ~]# wget https: //funchlscdn.lechange.cn/LCLR/2K02135PAK01979/0/0/20170726085033/dev_20170726085033_lpxh73ezzb92xxa8.m3u8
- --2017 - 07 - 26 16 : 08 : 15-- https: //funchlscdn.lechange.cn/LCLR/2K02135PAK01979/0/0/20170726085033/dev_20170726085033_lpxh73ezzb92xxa8.m3u8
- Resolving funchlscdn.lechange.cn... 120.92.158.134 Connecting to funchlscdn.lechange.cn | 120.92.158.134 | :443... connected.HTTP request sent,
- awaiting response... 502 Bad Gateway 2017 - 07 - 26 16 : 08 : 15 ERROR 502 : Bad Gateway.
在浏览器打开效果如图:
502 Bad Gateway
The proxy server received an invalid response from an upstream server.
_____
KSYUN ELB 1.0.0
同时发现金山云负载均衡里对 nginx 的 8000 健康检查是 "异常"。但是使用 http 访问却是可以的,效果如下:
- [[email protected] ~]# wget http: //funchlscdn.lechange.cn/LCLR/2K02135PAK01979/0/0/20170726085033/dev_20170726085033_lpxh73ezzb92xxa8.m3u8
- --2017 - 07 - 26 15 : 31 : 55-- http: //funchlscdn.lechange.cn/LCLR/2K02135PAK01979/0/0/20170726085033/dev_20170726085033_lpxh73ezzb92xxa8.m3u8
- Resolving funchlscdn.lechange.cn... 120.92.158.134 Connecting to funchlscdn.lechange.cn | 120.92.158.134 | :80... connected.HTTP request sent,
- awaiting response... 302 Found Location: http: //120.92.133.76:8090/LCLR/2K02135PAK01979/0/0/20170726085033/dev_20170726085033_lpxh73ezzb92xxa8.m3u8 [following]
- --2017 - 07 - 26 15 : 31 : 55-- http: //120.92.133.76:8090/LCLR/2K02135PAK01979/0/0/20170726085033/dev_20170726085033_lpxh73ezzb92xxa8.m3u8
- Connecting to 120.92.133.76 : 8090... connected.HTTP request sent,
- awaiting response... 200 OK Length: 66 [application / x - mpegURL] Saving to: "dev_20170726085033_lpxh73ezzb92xxa8.m3u8"100 % [ === =====================================================================================================================================================>] 66 --. - K / s in 0s 2017 - 07 - 26 15 : 31 : 55 (3.02 MB / s) - "dev_20170726085033_lpxh73ezzb92xxa8.m3u8" saved [66 / 66]
于是就叫来开发问一下 http 和 https 详细的流程,开发说在 http 里,设计路线如下:
- http(80) - >开发模块 (9001)
而在 https 里,设计路线如下:
- https(443) - >nginx(8000) - >开发模块 (9001)
这时候就发现了问题,原来最早的时候金山云是没有配置 https 证书的,于是开发们就用 nginx 的 8000 端口去监听 ssl 这样达到 https 证书的效果,但是后来金山云控制台添加了 https 证书,就不再需要 nginx 去配置 ssl 证书了,再去 https 监听 8000 这一步也就是错误的了,于是在负载均衡那里改成了:
- https(443) - >开发模块 (9001)
同时关闭了 nginx,这时候再来测试一下 https 请求,就成功了!
其实如果非要用 nginx 的 ssl 证书的话,那么的套路就是:开启 nginx,但是在负载均衡那里使用 tcp 协议去监听 nginx 的 8000 端口,这样一样能达到效果。
最后的最后,如果您觉得本文对您升职加薪有帮助,那么请不吝赞助之手,刷一下下面的二维码,赞助本人继续写更多的博文!
来源: http://www.bubuko.com/infodetail-2229778.html