Ranchers internal haproxy for websocket balancing

We have setup a short stack with a websocket server (lightstreamer) and need to balance this containers. Can we setup ranchers haproxy enabling proxy protocol ? Not sure which or how overwrite configuration.

we found several examples for running websockets with haproxy, i.e. https://medium.com/@Philmod/load-balancing-websockets-on-ec2-1da94584a5e9#.cvtlisspy

example docker-compose.yml

Lightstreamer:
log_driver: ''
labels:
io.rancher.container.pull_image: always
log_opt: {}
hostname: push
image: lightstreamer
lb:
ports:

  • 80:8080
    labels:
    io.rancher.scheduler.global: 'true’
    tty: true
    image: rancher/load-balancer-service
    links:
  • Lightstreamer:Lightstreamer
    stdin_open: true

rancher-compose.yml

Lightstreamer:
scale: 4
health_check:
port: 8080
interval: 2000
initializing_timeout: 60000
unhealthy_threshold: 3
strategy: recreate
response_timeout: 2000
healthy_threshold: 2
lb:
load_balancer_config:
haproxy_config: {}
health_check:
port: 42
interval: 2000
unhealthy_threshold: 3
healthy_threshold: 2
response_timeout: 2000

Hey.

I’m certain this is possible with little work. HAProxy has had built in support for websockets since 1.5 something.

Setup should be the same as for any HTTP service. You may want to add a tunnel timeout by adding timeout tunnel 3600s to the custom haproxy.cfg defaults section.

Ideally (as per the article you linked to) you should balance using the source IP address. I’m not sure if this is possible just yet in Rancher (and I’m too lazy to check), but well worth trying adding balance source to the same section I’ve mentioned.

That really should be all you need.

Thats working while accessing the ranchers loadbalancers directly ;-)! Thx.
If we have amazons elb in front… i think therefore we must activate the proxy protocol.
I found only one configuration setting in the binding setting

bind *:80 accept-proxy

Can i enable that in defaults,too ?

Good stuff, you’re welcome.

I didn’t realise you were actually using ELB too. From what I can tell can only specify accept-proxy with a bind statement. That being the case you’ll probably need to create and run your own HAProxy container image (which is what I do, but for different reasons).

I use Alpine for mine and even with confd it’s only 34MB.