OpenC3/cosmos

View on GitHub
openc3-traefik/traefik-allow-http.yaml

Summary

Maintainability
Test Coverage
---
# Listen for everything coming in on the standard HTTP port
entrypoints:
  web:
    address: ":2900"
http:
  middlewares:
    # Removes the first part of the url before passing onto the service
    # ie. /openc3-api/api becomes /api
    removeFirst:
      replacePathRegex:
        regex: "^/([^/]*)/(.*)"
        replacement: "/$2"
    # Serve /tools/base/index.html
    gotoToolsBaseIndex:
      replacePath:
        path: "/tools/base/index-allow-http.html"
    # Adds /tools/base to the beginning of the given url
    # ie. /index.html becomes /tools/base/index.html
    addToolsBase:
      replacePathRegex:
        regex: "^/(.*)"
        replacement: "/tools/base/$1"
    # Adds index.html to the end of the given url
    # ie. /tools/staticdocs/ becomes /tools/staticdocs/index.html
    addIndexHtml:
      replacePathRegex:
        regex: "^(.*)/$"
        replacement: "$1/index.html"
    # Adds .html to the end of the given url
    # ie. /tools/staticdocs/docs becomes /tools/staticdocs/docs.html
    addDotHtml:
      replacePathRegex:
        regex: "^(.*)$"
        replacement: "$1.html"
  routers:
    # Note: Priorities control router check order with highest priority evaluated first
    # Route to the openc3 cmd/tlm api
    api-router:
      rule: PathPrefix(`/openc3-api`)
      service: service-api
      priority: 8
    # Route to the script api
    script-router:
      rule: PathPrefix(`/script-api`)
      service: service-script
      priority: 7
    # Route to other tool plugins hosted statically in Minio
    # Matches any path with a file extension which is assumed to be
    # a static file
    tools-router:
      rule: Path(`/tools/{id:.*/.*[.].*}`)
      service: service-minio
      priority: 6
    # Route to other tool plugins hosted statically in Minio
    # Where we need to add index.html to the path
    # Matches any tool name that starts with static and ends with slash
    statictools-index-router:
      rule: Path(`/tools/static{rest:.*}/`)
      middlewares:
        # add index.html to the end
        - "addIndexHtml"
      service: service-minio
      priority: 5
    # Route to other tool plugins hosted statically in Minio
    # Where we need to add .html to the path
    # Matches any tool name that starts with static
    statictools-dothtml-router:
      rule: Path(`/tools/static{rest:.*}`)
      middlewares:
        # add .html to the end
        - "addDotHtml"
      service: service-minio
      priority: 4
    # Route to any path in minio
    files-router:
      rule: PathPrefix(`/files`)
      middlewares:
        # remove /files from the beginning
        - "removeFirst"
      service: service-minio
      priority: 3
    # Route to base files hosted statically in Minio
    # Matches any path with a file extension which is assumed to be
    # a static file
    base-router:
      rule: Path(`/{id:.*[.].*}`)
      middlewares:
        # add /tools/base to the beginning
        - "addToolsBase"
      service: service-minio
      priority: 2
    # This is the default route for everything that doesn't match a more specific route
    # It gets us to the base openc3 application
    web-router:
      rule: HostRegexp(`{name:.*}`)
      middlewares:
        # Serve /tools/base/index.html from minio
        - "gotoToolsBaseIndex"
      service: service-minio
      priority: 1
  services:
    # The OpenC3 cmd/tlm api service
    service-api:
      loadBalancer:
        passHostHeader: false
        servers:
          - url: "http://openc3-cosmos-cmd-tlm-api:2901"
    # The OpenC3 script api service
    service-script:
      loadBalancer:
        passHostHeader: false
        servers:
          - url: "http://openc3-cosmos-script-runner-api:2902"
    # The Minio S3 file server
    service-minio:
      loadBalancer:
        passHostHeader: false
        servers:
          - url: "http://openc3-minio:9000"
# Declare the routes are currently coming from this file, not dynamically
providers:
  file:
    filename: /etc/traefik/traefik.yaml
  http:
    endpoint: "http://openc3-cosmos-cmd-tlm-api:2901/openc3-api/traefik"
    pollInterval: "5s"
accessLog: {}
# api:
#   dashboard: true
#   insecure: true
# log:
#   filePath: '/etc/traefik/traefik.log'
#   level: 'DEBUG'
# accessLog:
#   filePath: '/etc/traefik/access.log'
#   fields:
#     defaultMode: keep
#     headers:
#       defaultMode: keep