Logo
ХелпдескУправление знаниямиБизнесуТарифыЧто такое KCS?Блог
Русский
Личный кабинет
Настройка системы
© 2023 - 2026 ООО «Свормика». Swarmica - Платформа управления знаниями и ресурсами техподдержки. Версия: 6.1.2

#1232: Is it possible to maintain Russian and foreign circuits as a single scheme?

Отредактирована: сегодня

Symptoms

Configuration with multiple load balancers.
It is necessary to set up two or more showcases that will be located in different geographical locations and with different domain names that will go to the same Swarmica instance. How can this be done?

Solution

This article provides a solution for two external nginx load balancers; by analogy, the solution can be applied to a different number and types of load balancers.

Preparing Swarmica

  1. In the file /root/swarmica/.env, add the addresses of the load balancers to the DJANGO_ALLOWED_HOSTS variable:
DJANGO_ALLOWED_HOSTS=my.swarmica.tld,balancer1.swarmica.tld,balancer2.swarmica.tld
  1. In the file /root/swarmica/docker-compose.yml, wherever the Host directive is used, add the addresses of the load balancers, for example, like this:
services:

  frontend:
    image: reg.gl.swd.im/swarmica/frontend:${SW_FRONTEND_VERSION}
    depends_on:
      - django
    restart: always
    volumes:
      - ./robots.txt:/robots.txt:ro
      - swarmica_static:/admin_static:ro
      - swarmica_ugc:/attachments:ro
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.nginx.entrypoints=web-secure"
      - "traefik.http.routers.nginx.rule=Host(`{SW_HOSTNAME}`) || Host(balancer1.swarmica.tld) || Host(balancer2.swarmica.tld)"
      - "traefik.http.routers.nginx.tls.certresolver=letsencrypt"
      - "traefik.http.routers.nginx.middlewares=secure-headers,compression"
      - "traefik.http.routers.nginx.priority=10"

Typically, this needs to be done for the frontend, django, django-websocket, helpcenter services.

  1. Restart the services:
sudo su -
cd /root/swarmica
docker compose down
docker compose up -d

Load Balancer Settings (nginx)

  1. First, install and configure nginx on each load balancer.

  2. Get SSL certificates for the domain names and add them to the nginx configuration.

  3. In the server directive of the site (virtual host) that handles the domain name of the load balancer, replace the section responsible for location /, so that you get the following configuration:

server {
        listen 80 default_server;
        listen [::]:80 default_server;

        listen 443 ssl;
        server_name balancer1.swarmica.tld;

        ssl_certificate /etc/nginx/ssl/balancer1.swarmica.tld.crt;
        ssl_certificate_key /etc/nginx/ssl/balancer1.swarmica.tld.key;

        ssl_protocols TLSv1.2 TLSv1.3;
        ssl_ciphers HIGH:aNULL:MD5;

        root /var/www/html;

        index index.html index.htm index.nginx-debian.html;

        server_name _;

        location / {
                proxy_pass              https://my.swarmica.tld;
                proxy_set_header        Host    $host;
                proxy_set_header        X-Forwarded-For $remote_addr;
                add_header              X-Upstream      $upstream_addr;
        }
}
  1. Restart nginx:
invoke-rc.d nginx restart
  1. If different brands are to be used, then the brand can be specified through a header in the load balancers:
proxy_set_header     X-Swarmica-Brand: UID