# Traefik file provider for P5G Marvis + P5G Radio
# Place at /etc/athonet/traefik/ssl/marvis.yml (the ssl/ dir is mounted into the container)
# The file provider path in traefik.yml must reference /etc/traefik/ssl/marvis.yml

http:
  routers:
    router-marvis-0:
      rule: "PathPrefix(`/core/marvis`)"
      service: service-marvis
      entryPoints:
        - websecure
      tls: {}
      # priority > 19 to beat pls-error@http which also matches PathPrefix(`/core`)
      priority: 25
      middlewares:
        - cors@http
        - strip-path-marvis-0

    router-radio-0:
      rule: "PathPrefix(`/core/radio`)"
      service: service-radio
      entryPoints:
        - websecure
      tls: {}
      priority: 25
      middlewares:
        - cors@http
        - strip-path-radio-0

    # Route rm-ui static assets (absolute paths in the SPA HTML) directly to rm-ui.
    # These exact hashes are unique to rm-ui so they won't conflict with NCM assets.
    router-radio-js:
      rule: "Path(`/assets/index-9Haqbm6c.js`)"
      service: service-radio
      entryPoints:
        - websecure
      tls: {}
      priority: 30

    router-radio-css:
      rule: "Path(`/assets/index-BKG23XBM.css`)"
      service: service-radio
      entryPoints:
        - websecure
      tls: {}
      priority: 30

    # Route rmf API calls from inside the radio iframe to the rmf backend.
    # Must be more specific than PLS's PathPrefix(`/api/1`) catch-all.
    router-radio-api:
      rule: "PathPrefix(`/api/1/radio`)"
      service: service-rmf
      entryPoints:
        - websecure
      tls: {}
      priority: 26

  middlewares:
    strip-path-marvis-0:
      stripPrefix:
        prefixes:
          - "/core/marvis"

    strip-path-radio-0:
      stripPrefix:
        prefixes:
          - "/core/radio"

  services:
    service-marvis:
      loadBalancer:
        servers:
          - url: "http://127.0.0.1:8100"
        passHostHeader: false

    service-radio:
      loadBalancer:
        servers:
          - url: "http://127.0.0.1:4000"
        passHostHeader: false

    service-rmf:
      loadBalancer:
        servers:
          - url: "http://192.168.86.173:8101"
        passHostHeader: false
