Nginx 实现HTTPS与SSH端口复用
通过 ngx_stream_ssl_preread_module 模块(1.11.5) 实现HTTPS和SSH共用一个端口
根据 $ssl_preread_protocol 变量 判断SSL协议版本,选择上游。使ssh连接到ssh端口,HTTPS连接到https端口
nginx版本必须大于1.15.2,因为 nginx 1.15.2 版本之后新增了一个属性$ssl_preread_protocol,可以让stream区分web ssl/tls和其他协议
流程
1.ssh端口
2.https端口
3.通过stream模块实现四层协议的转发,根据 $ssl_preread_protocol 判断进入ssh还是https端口