exoframejs / exoframe

Exoframe is a self-hosted tool that allows simple one-command deployments using Docker
https://exoframejs.github.io/exoframe/
1.13k stars 56 forks source link

Allow using custom traefik middlewares from exoframe config #278

Closed yamalight closed 4 years ago

yamalight commented 4 years ago

Currently there's no way to define additional custom middleware via exoframe config because Traefik v2.0 requires new middlewares to be explicitly included into the list on router. There are two possible options:

  1. Automatically parse all given user labels, look for labels that start with traefik.http.middlewares, extract name and auto-add it to middlewares list, e.g. adding redirect would be:
    {
    "labels": {
    "traefik.http.middlewares.my-redirectregex.redirectregex.regex": "^https://domain.redirect/(.*)",
    "traefik.http.middlewares.my-redirectregex.redirectregex.replacement": "https://domain.new/$${1}"
    }
    }
  2. Introduce additional middlewares property that should list middlewares in traefik format, e.g. adding redirect would be:
    {
    "labels": {
    "traefik.http.middlewares.my-redirectregex.redirectregex.regex": "^https://domain.redirect/(.*)",
    "traefik.http.middlewares.my-redirectregex.redirectregex.replacement": "https://domain.new/$${1}"
    },
    "middlewares": ["my-redirectregex@docker"],
    }

First option is easier for basic stuff, while second is more powerful (allows using middlewares from traefik config, etc). Maybe a combination of two would be best.