小编Joh*_*ohn的帖子

如何让HAProxy基于SNI路由TCP(使用openssl s_client测试)?

我想使用 HAProxy 终止 TLS 加密的 TCP 连接,并根据用于启动 TLS 连接的服务器名称指示将未加密的 TCP 流量传递到各个后端。

我在后端服务器上运行 3 个服务,每个服务都在不同的端口(5001、5002、5003)上。HAProxy 绑定到端口 5000。我想按名称将连接路由到前 2 个服务,如果不匹配,则路由到第三个服务。我正在使用 启动与 HAProxy 的连接openssl s_client。但是,在日志中我可以看到连接仅路由到默认服务器,即 SNI 似乎被忽略。

域名系统:

A record     demo.sni.example.com     1.2.3.4
CNAME        1.sni.example.com        pointing to demo.sni.example.com   
CNAME        2.sni.example.com        pointing to demo.sni.example.com   
Run Code Online (Sandbox Code Playgroud)

即我希望发生以下路由:

SNI = 1.sni.example.com:5000 -> 1.2.3.4:5001
SNI = 2.sni.example.com:5000 -> 1.2.3.4:5002
anything else on port 5000 -> 1.2.3.4:5003
Run Code Online (Sandbox Code Playgroud)

haproxy.cfg:

global
  log stdout  format raw  local0 info

defaults
  timeout client 30s
  timeout server 30s
  timeout connect 5s
  option tcplog

frontend …
Run Code Online (Sandbox Code Playgroud)

ssl openssl haproxy sni

5
推荐指数
1
解决办法
2万
查看次数

标签 统计

haproxy ×1

openssl ×1

sni ×1

ssl ×1