TCP passthroughs不适用于80端口

时间:2017-06-15 07:52:02

标签: tcp haproxy

您好我正在尝试使用基于SNI的TCP passthrough。它适用于SSL,但它不能用于80.

配置如下:

global
log         127.0.0.1 local2
chroot      /var/lib/haproxy
pidfile     /var/run/haproxy.pid
maxconn     4000
user        haproxy
group       haproxy
daemon
stats socket /var/lib/haproxy/stats
defaults
 timeout client 30s
 timeout server 30s
 timeout connect 5s

frontend https
 bind *:443
 mode tcp
 tcp-request inspect-delay 5s
 tcp-request content accept if { req_ssl_hello_type 1 }
 acl mytonicssl req_ssl_sni -i staging.mytonic.com
 use_backend mytonic-ssl if mytonicssl


 backend mytonic-ssl
 mode tcp
 balance roundrobin
 stick-table type binary len 32 size 30k expire 30m
 acl clienthello req_ssl_hello_type 1
 acl serverhello rep_ssl_hello_type 2
 tcp-request inspect-delay 5s
 tcp-request content accept if clienthello
 tcp-response content accept if serverhello
 stick on payload_lv(43,1) if clienthello
 stick store-response payload_lv(43,1) if serverhello
 option ssl-hello-chk
 server server1 10.10.17.222:8443 check

 frontend http
 bind *:80
 mode tcp
 acl mytonic_http hdr_dom(host) -i staging.mytonic.com
 use_backend mytonic_nonssl if mytonic_http


 backend mytonic_nonssl
 mode tcp
 balance roundrobin
 server server1 10.10.17.222:8080 check

如果我添加默认后端,那么它可以工作。但这不是虚拟主机解决方案。我的haproxy版本是:HA-Proxy版本1.5.18 2016/05/10任何帮助表示赞赏。

1 个答案:

答案 0 :(得分:1)

SNI是一个TLS扩展,其中包含目标主机名。由于它是TLS扩展,因此只能与SSL / TLS流量一起使用。具有普通HTTP(即没有SSL / TLS)的匹配机制是HTTP主机头。但要基于此标头进行平衡,您需要使用模式http(默认值)而不是模式tcp。另请参阅How to divert traffic based on hostname using HAProxy?

相关问题