TCP 直通不适用于 80 端口
TCP passthroughs is not working for 80 port
您好,我正在尝试实现基于 SNI 的 TCP 直通。它适用于 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 任何帮助表示赞赏。
SNI 是包含目标主机名的 TLS 扩展。由于它是 TLS 扩展,因此只能用于 SSL/TLS 流量。与纯 HTTP(即无 SSL/TLS)的匹配机制是 HTTP 主机 header。但是要基于此 header 进行平衡,您需要使用模式 http(默认)而不是模式 tcp。另见 How to divert traffic based on hostname using HAProxy?
您好,我正在尝试实现基于 SNI 的 TCP 直通。它适用于 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 任何帮助表示赞赏。
SNI 是包含目标主机名的 TLS 扩展。由于它是 TLS 扩展,因此只能用于 SSL/TLS 流量。与纯 HTTP(即无 SSL/TLS)的匹配机制是 HTTP 主机 header。但是要基于此 header 进行平衡,您需要使用模式 http(默认)而不是模式 tcp。另见 How to divert traffic based on hostname using HAProxy?