2017-06-15 82 views
0

您好我試圖實現基於SNI使用TCP直通。它適用於SSL,但它不工作了80TCP passthroughs不工作的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代理版本1.5.18 2016/05/10任何幫助表示讚賞。

回答

1

SNI是一個包含目標主機名的TLS擴展。由於它是TLS擴展名,因此只能與SSL/TLS流量一起使用。具有普通HTTP(即無SSL/TLS)的匹配機制是HTTP主機頭。但要基於這個頭部來平衡,你需要使用模式http(默認)而不是模式tcp。另見How to divert traffic based on hostname using HAProxy?