docker-traefik-cloudflare-companion icon indicating copy to clipboard operation
docker-traefik-cloudflare-companion copied to clipboard

Support for defaultRule

Open Mbarmem opened this issue 4 years ago • 4 comments

Instead of defining Host label under each service, i have a default rule in the traefik.yml configuration as shown below:

providers:
  docker:
    endpoint: "unix:///var/run/docker.sock"
    exposedByDefault: false
    swarmMode: false
    network: traefik_2
    defaultRule: "Host(`{{ index .Labels \"com.docker.compose.service\"}}.domain.com`)"

Is their any work around for this scenario or possibility to add support?

Mbarmem avatar Jul 30 '20 13:07 Mbarmem

Really need this feature, too

SaltOfTheFlame avatar Nov 01 '20 21:11 SaltOfTheFlame

A possible solution would be to get the hostnames via traefik v2 api (https://doc.traefik.io/traefik/operations/api/). The endpoint /api/http/routers contains every Host rule for all routers. This solution also avoids using the docker socket.

mpalet avatar Jan 26 '21 15:01 mpalet

Not being able to use the defaultRule kind of defeats its purpose of the default rule, which is extremely practical when using numerous containers. I agree that adding support for this would really be useful!

axl7777 avatar Jun 22 '21 15:06 axl7777

I too am effected by this.

KaHooli avatar Feb 17 '22 05:02 KaHooli

I have a current workaround. I have downloaded and edited the main file and loaded into the container as a config. I removed only 1 line from the file: line 308 (and fixed indentation caused by it) if "provider" in router and router["provider"] != "docker":

My current workaround file

      configs:
      - source: traefik-cloudflare-companion__fix
        target: /usr/sbin/cloudflare-companion
        mode: 0755

mxmeeple avatar Oct 26 '22 16:10 mxmeeple