Cannot get v2 working as reverse proxy with docker & LE "no args for matcher Host"

I am trying to migrate from v1.7 to v2.4 using docker containers and Lets Encrypt certs.

Here are my config files:
traefik.toml

[entryPoints]
  [entryPoints.web]
    address = ":80"
    [entryPoints.web.http.redirections.entryPoint]
      to = "websecure"
      scheme = "https"

  [entryPoints.websecure]
    address = ":443"

[api]
  dashboard = true

[certificatesResolvers.lets-encrypt.acme]
  email = "a@a.com"
  storage = "acme.json"
  [certificatesResolvers.lets-encrypt.acme.tlsChallenge]

[providers.docker]
  watch = true
  network = "web"

[providers.file]
  filename = "traefik_dynamic.toml"

traefik_dynamic.toml

[http.middlewares.simpleAuth.basicAuth]
  users = [
    "admin:pwhash"
  ]

[http.routers.api]
  rule = "Host(`sub.domain.com`)"
  entrypoints = ["websecure"]
  middlewares = ["simpleAuth"]
  service = "api@internal"
  [http.routers.api.tls]
    certResolver = "lets-encrypt"

Docker run:

docker run -d \
        --name test \
        --restart unless-stopped \
        --network traefik_entrypoint \
        -l traefik.http.routers.internal.rule=Host\(`sub.domain.com`\) \
        -l traefik.http.routers.internal.tls=true \
        -l traefik.http.routers.internal.tls.certresolver=lets-encrypt \
        -l traefik.port=80 \
        nginx

I get this error in the docker logs and on the dashboard:

level=error msg="no args for matcher Host" entryPointName=websecure routerName=internal@docker

What am I doing wrong?

Your backticks are not escaped with your docker run ... command so command substitution is occurring and resulting in an empty string.

Inspect your container and you will see:

            "Labels": {
                "traefik.http.routers.internal.rule": "Host()"
                 ...
                 ...
                 ...
            }
1 Like

Thank you!!!
Silly mistake, I assumed it was an issue with how I was setting up Traefik, not a bash issue facepalm

1 Like