我正在尝试使用HAProxy设置Websockets,具有以下配置: http流量 - > haproxy - >清漆 - > nginx - >节点 ws traffic - > haproxy - >节点
一个子域已强制ssl,因此haproxy将任何http流量重定向到https。 (并且ws to wss)
除了一个问题外,一切都按预期工作,不断创建新套接字而不只是一个(我可以看到它们在Chrome的调试控制台中每隔几秒创建一次)
当我使用Varnish来执行Websockets管道时,我没有遇到这个问题。
我该如何解决这个问题?
global
daemon
defaults
mode http
frontend insecure
# HTTP
bind :80
timeout client 5000
# acl
acl is_console hdr_end(host) -i console.mydomain.com
acl is_client hdr_end(host) -i www.mydomain.com
acl is_websocket hdr(Upgrade) -i WebSocket
acl is_websocket hdr_beg(Host) -i ws
# Redirect all HTTP traffic to HTTPS
redirect location https://console.mydomain.com if is_console
use_backend node_console if is_console is_websocket
use_backend node_client if is_client is_websocket
default_backend varnish
frontend secure
# HTTPS
bind :443 ssl crt /etc/ssl/console.mydomain.com.pem
timeout client 5000
# acl
acl is_console hdr_end(host) -i console.mydomain.com
acl is_client hdr_end(host) -i www.mydomain.com
acl is_websocket hdr(Upgrade) -i WebSocket
acl is_websocket hdr_beg(Host) -i ws
use_backend dealspot_console if is_console is_websocket
use_backend dealspot_client if is_client is_websocket
default_backend varnish
backend varnish
balance leastconn
option forwardfor
timeout server 5000
timeout connect 4000
server varnish1 127.0.0.1:6081
backend node_client
balance leastconn
option forwardfor
timeout queue 5000
timeout server 5000
timeout connect 5000
server client_node1 127.0.0.1:3000
backend node_console
balance leastconn
option forwardfor
timeout queue 5000
timeout server 5000
timeout connect 5000
server console_node1 127.0.0.1:3001
答案 0 :(得分:1)
我设法通过在后端设置'隧道超时'一天来解决这个问题