# docker-dev companion to scripts/install/traefik-dynamic.yml. Routes three
# Akka clusters that share the Compose network:
#
#   - Main cluster (default): PathPrefix(`/`) → admin-a / admin-b.
#   - Site A cluster:         Host(`site-a.localhost`) → site-a-1 / site-a-2.
#   - Site B cluster:         Host(`site-b.localhost`) → site-b-1 / site-b-2.
#
# Host-header rules are more specific than PathPrefix, so they win over the
# default router for the site hostnames automatically — no priority field needed.

http:
  routers:
    otopcua-admin:
      entryPoints: ["web"]
      rule: "PathPrefix(`/`)"
      service: otopcua-admin

    otopcua-site-a:
      entryPoints: ["web"]
      rule: "Host(`site-a.localhost`)"
      service: otopcua-site-a

    otopcua-site-b:
      entryPoints: ["web"]
      rule: "Host(`site-b.localhost`)"
      service: otopcua-site-b

  services:
    otopcua-admin:
      loadBalancer:
        # Blazor Server uses SignalR; the WebSocket upgrade must hit the same
        # backend that owns the circuit ID. Sticky cookie keeps each session
        # pinned to one node so the post-handshake WebSocket doesn't 404.
        sticky:
          cookie:
            name: otopcua_lb
            httpOnly: true
            sameSite: lax
        servers:
          - url: "http://admin-a:9000"
          - url: "http://admin-b:9000"
        healthCheck:
          path: /health/active
          interval: 5s
          timeout: 2s

    otopcua-site-a:
      loadBalancer:
        # Blazor Server uses SignalR; the WebSocket upgrade must hit the same
        # backend that owns the circuit ID. Sticky cookie keeps each session
        # pinned to one node so the post-handshake WebSocket doesn't 404.
        sticky:
          cookie:
            name: otopcua_lb
            httpOnly: true
            sameSite: lax
        servers:
          - url: "http://site-a-1:9000"
          - url: "http://site-a-2:9000"
        healthCheck:
          path: /health/active
          interval: 5s
          timeout: 2s

    otopcua-site-b:
      loadBalancer:
        # Blazor Server uses SignalR; the WebSocket upgrade must hit the same
        # backend that owns the circuit ID. Sticky cookie keeps each session
        # pinned to one node so the post-handshake WebSocket doesn't 404.
        sticky:
          cookie:
            name: otopcua_lb
            httpOnly: true
            sameSite: lax
        servers:
          - url: "http://site-b-1:9000"
          - url: "http://site-b-2:9000"
        healthCheck:
          path: /health/active
          interval: 5s
          timeout: 2s
