# Ranchers internal haproxy for websocket balancing

**URL:** <https://forums.suse.com/t/ranchers-internal-haproxy-for-websocket-balancing/2485>\
**Category:** Rancher 1.x\
**Created:** [April 16, 2016, 1:16pm UTC](https://forums.suse.com/t/ranchers-internal-haproxy-for-websocket-balancing/2485 "2016-04-16T13:16:46Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![frintrop](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/frintrop/32/1119_2.png) [@frintrop](https://forums.suse.com/u/frintrop)\
**Post date:** [April 16, 2016, 1:16pm UTC](https://forums.suse.com/t/ranchers-internal-haproxy-for-websocket-balancing/2485/1 "2016-04-16T13:16:46Z")

</div>

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](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

---

<div class="post-metadata">

**Author:** ![sjiveson](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/sjiveson/32/966_2.png) [@sjiveson](https://forums.suse.com/u/sjiveson)\
**Post date:** [April 18, 2016, 9:20am UTC](https://forums.suse.com/t/ranchers-internal-haproxy-for-websocket-balancing/2485/2 "2016-04-18T09:20:49Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![frintrop](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/frintrop/32/1119_2.png) [@frintrop](https://forums.suse.com/u/frintrop)\
**Post date:** [April 18, 2016, 4:28pm UTC](https://forums.suse.com/t/ranchers-internal-haproxy-for-websocket-balancing/2485/3 "2016-04-18T16:28:05Z")

</div>

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 ?

---

<div class="post-metadata">

**Author:** ![sjiveson](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/sjiveson/32/966_2.png) [@sjiveson](https://forums.suse.com/u/sjiveson)\
**Post date:** [April 19, 2016, 8:57am UTC](https://forums.suse.com/t/ranchers-internal-haproxy-for-websocket-balancing/2485/4 "2016-04-19T08:57:50Z")

</div>

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.
