ssl HAProxy重定向TCP模式下的HTTP

lmyy7pcs  于 2023-05-18  发布在  HAProxy
关注(0)|答案(1)|浏览(109)

我试图重定向HTTP请求在一个给定的端口,但不断得到错误SSL握手失败。
在HAProxy 2.2.25中,我有一个非常类似的设置,可以工作(但不会终止SSL)。

frontend smqtt
    bind :8883
    mode tcp
    tcp-request inspect-delay 5s
    tcp-request content capture req.proto_http len 1
    use_backend port_check if HTTP
    default_backend smqtt-broker
backend smqtt-broker
    mode tcp
    server Broker1 <ip-address> check
backend port_check
    mode http
    http-request return content-type "text/plain" string "Port Check Success"

当我在HAProxy 2.6.9中尝试类似的设置时,它不起作用(但有TLS终止)

frontend smqtt
    bind :8883 ssl crt <path_to_crt> verify required ca-file <path_to_ca>
    mode tcp
    tcp-request inspect-delay 5s
    tcp-request content capture req.proto_http len 1
    use_backend port_check if HTTP
    default_backend brokers
backend port_check
    mode http
    http-request return content-type "text/plain" string "Port Check Success"
backend brokers
    mode tcp
    server Broker1 <ip-address> check

设置几乎相同,除了第一个没有终止TLS连接,第二个终止TLS。
如何重定向给定的HTTP请求?

mcdcgff0

mcdcgff01#

预定义的ACL HTTP被定义为req.proto_http,这意味着HAProxy必须解密TLS并开始分析请求,这在TCP模式下不会完成。
从我的观点来看,你有几种选择
1.基于SNI头路由请求,如How haproxy uses sni to spread traffic中所回答的,这是我的首选解决方案。
1.在http模式下添加另一个前端并使用此。
1.在tcp前端中添加另一个纯文本绑定行

相关问题