Created
October 16, 2018 06:06
-
-
Save onigoetz/9b49b4b3e713e35cd2e51f4b369ca2e7 to your computer and use it in GitHub Desktop.
Rocket Chat sticky load balancing with docker-compose and haproxy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '2' | |
services: | |
rocketchat1: | |
image: rocketchat/rocket.chat:0.65.1 | |
restart: unless-stopped | |
volumes: | |
- ./uploads:/app/uploads | |
environment: | |
- PORT=3000 | |
- ROOT_URL=http://192.168.64.28 | |
- MONGO_URL=mongodb://mongo:27017/rocketchat | |
- MONGO_OPLOG_URL=mongodb://mongo:27017/local | |
depends_on: | |
- mongo | |
rocketchat2: | |
image: rocketchat/rocket.chat:0.65.1 | |
restart: unless-stopped | |
volumes: | |
- ./uploads:/app/uploads | |
environment: | |
- PORT=3000 | |
- ROOT_URL=http://192.168.64.28 | |
- MONGO_URL=mongodb://mongo:27017/rocketchat | |
- MONGO_OPLOG_URL=mongodb://mongo:27017/local | |
depends_on: | |
- mongo | |
mongo: | |
image: mongo:latest | |
restart: unless-stopped | |
volumes: | |
- ./data/runtime/db:/data/db | |
- ./data/dump:/dump | |
ports: | |
- 27017:27017 | |
command: mongod --smallfiles --oplogSize 128 --replSet rs0 | |
haproxy: | |
image: haproxy:1.4.27 | |
restart: unless-stopped | |
volumes: | |
- ./haproxy.conf:/usr/local/etc/haproxy/haproxy.cfg:ro | |
ports: | |
- 80:80 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Requires recent Haproxy to work with websockets (for example 1.4.16). | |
#global | |
# log /dev/stdout | |
# log 127.0.0.1 local2 debug | |
defaults | |
log global | |
mode http | |
option httplog | |
option dontlognull | |
retries 3 | |
option redispatch | |
# Set timeouts to your needs | |
timeout client 60s | |
timeout connect 60s | |
timeout server 60s | |
frontend all 0.0.0.0:80 | |
mode http | |
timeout client 120s | |
# option httplog | |
option forwardfor | |
# Fake connection:close, required in this setup. | |
#option http-server-close | |
#option http-pretend-keepalive | |
acl is_websocket path_beg /sockjs | |
acl is_websocket hdr(Upgrade) -i WebSocket | |
acl is_websocket hdr_beg(Host) -i ws | |
acl is_stats path_beg /haproxy_stats | |
use_backend websockets if is_websocket | |
use_backend stats if is_stats | |
default_backend meteor | |
backend meteor | |
balance source | |
server rocketchat1 rocketchat1:3000 weight 1 | |
server rocketchat2 rocketchat2:3000 weight 1 | |
backend websockets | |
balance source | |
option http-server-close | |
option forceclose | |
server rocketchat1 rocketchat1:3000 weight 1 | |
server rocketchat2 rocketchat2:3000 weight 1 | |
backend stats | |
stats uri /haproxy_stats | |
stats enable |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment