From dc1269358a7cf9b5cc11d3293d543fb5f2c3e550 Mon Sep 17 00:00:00 2001 From: Gabriel Petry <24570030+gabrielpetry@users.noreply.github.com> Date: Thu, 13 Nov 2025 11:49:07 -0300 Subject: [PATCH 1/4] feat: Introduce ROCKETCHAT_BACKEND_SERVERS env var for Traefik --- compose.traefik.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/compose.traefik.yml b/compose.traefik.yml index 28f7497..54e46f1 100644 --- a/compose.traefik.yml +++ b/compose.traefik.yml @@ -2,6 +2,8 @@ services: traefik-init: image: docker.io/alpine:latest entrypoint: sh + environment: + ROCKETCHAT_BACKEND_SERVERS: ${ROCKETCHAT_BACKEND_SERVERS:-rocketchat:3000} command: - -c - |- From f3b12dddc31aed1354fea9bdd1d2ecc97ac55c45 Mon Sep 17 00:00:00 2001 From: Gabriel Petry <24570030+gabrielpetry@users.noreply.github.com> Date: Thu, 13 Nov 2025 11:49:07 -0300 Subject: [PATCH 2/4] feat: Dynamically configure Rocket.Chat backends in Traefik --- compose.traefik.yml | 51 +++++++++++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 20 deletions(-) diff --git a/compose.traefik.yml b/compose.traefik.yml index 54e46f1..fa4968c 100644 --- a/compose.traefik.yml +++ b/compose.traefik.yml @@ -11,7 +11,30 @@ services: # quote 'eof' to prevent variable expansion rm -rf /traefik_config/* || true mkdir -p /traefik_config/http /traefik_config/https - cat <<'EOF' | tee /traefik_config/http/dynamic.yml + # this should be idented so it works inside the heredoc concatenation later + cat <<'EOF' > /traefik_config/services.tpl + services: + grafana: + loadBalancer: + servers: + - url: "http://grafana:3000" + rocketchat: + loadBalancer: + healthCheck: + path: /health + interval: 10s + timeout: 3s + servers: + EOF + + echo "ROCKETCHAT_BACKEND_SERVERS $$ROCKETCHAT_BACKEND_SERVERS" + # append the server list to the services template + for server in $(echo $$ROCKETCHAT_BACKEND_SERVERS | tr "," "\n"); do + echo " - url: \"http://$$server\"" >> /traefik_config/services.tpl + done + + + cat <<'EOF' > /traefik_config/http/dynamic.yml http: routers: rocketchat: @@ -29,18 +52,9 @@ services: {{ else }} Host(`{{ env "GRAFANA_DOMAIN" }}`) {{ end }} - services: - rocketchat: - loadBalancer: - servers: - - url: "http://rocketchat:3000" - grafana: - loadBalancer: - servers: - - url: "http://grafana:3000" EOF - cat <<'EOF' | tee /traefik_config/https/dynamic.yml + cat <<'EOF' > /traefik_config/https/dynamic.yml https: address: ":443" http: @@ -69,17 +83,14 @@ services: service: grafana tls: certResolver: le - services: - rocketchat: - loadBalancer: - servers: - - url: "http://rocketchat:3000" - grafana: - loadBalancer: - servers: - - url: "http://grafana:3000" EOF + cat /traefik_config/services.tpl >> /traefik_config/http/dynamic.yml + cat /traefik_config/services.tpl >> /traefik_config/https/dynamic.yml + cat /traefik_config/http/dynamic.yml + echo "-------------------------" + cat /traefik_config/https/dynamic.yml + echo "files generated, keeping container alive to podman-compose detect it" tail -f /dev/null From 89e66dbded392075f35da125efac3c2e3f57ae97 Mon Sep 17 00:00:00 2001 From: Gabriel Petry <24570030+gabrielpetry@users.noreply.github.com> Date: Thu, 13 Nov 2025 11:49:08 -0300 Subject: [PATCH 3/4] docs: Add multiple server configuration to README --- README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/README.md b/README.md index 87b3031..a314fc7 100644 --- a/README.md +++ b/README.md @@ -126,3 +126,14 @@ podman compose \ -f compose.yml \ up -d ``` + + +--- + +### Multiple servers +When running multiple Rocket.Chat servers, you can configure Traefik to discover those servers and include them in load balancing by adding a variable in the `.env` file: + +```env +ROCKETCHAT_BACKEND_SERVERS=rocketchat-1:3000,rocketchat-2:3000,rocketchat-3:3000 +``` + From c03198c7dfa9641e76ef3edb44b52e03d80c1cf5 Mon Sep 17 00:00:00 2001 From: Debdut Chakraborty Date: Tue, 2 Dec 2025 18:12:28 +0530 Subject: [PATCH 4/4] Apply suggestion from @debdutdeb --- compose.traefik.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compose.traefik.yml b/compose.traefik.yml index fa4968c..54e6ec0 100644 --- a/compose.traefik.yml +++ b/compose.traefik.yml @@ -29,7 +29,7 @@ services: echo "ROCKETCHAT_BACKEND_SERVERS $$ROCKETCHAT_BACKEND_SERVERS" # append the server list to the services template - for server in $(echo $$ROCKETCHAT_BACKEND_SERVERS | tr "," "\n"); do + for server in $(echo $$ROCKETCHAT_BACKEND_SERVERS | tr "," "\n" | tr -d " "); do echo " - url: \"http://$$server\"" >> /traefik_config/services.tpl done