I'm trying to setup Websockets with HAProxy, with the following configuration: http traffic -> haproxy -> varnish -> nginx -> node ws traffic -> haproxy -> node
one subdomain has forced ssl so haproxy redirect any http traffic to https. (and ws to wss)
everything is working as expected except one issue, new sockets are constantly being created instead of just one (I can see them being created every few seconds in Chrome's debugging console)
I didn't have this problem when I used Varnish to do the Websockets pipe.
how can I fix this ?
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
I managed to fix that by setting 'tunnel timeout' to one day on the backends