Traefik not finding services from consul

The docs are very very sparse on the traefik consul integeration.

For the Nomad job I have configured the following:

   args = [
     # "--log.level=DEBUG",
     # "--api.insecure=true",
     # consul
     "--providers.consulCatalog=true",
     "--providers.consulCatalog.prefix=nodejs",
     "--providers.consulCatalog.exposedByDefault=false",
     # ports
     "--entrypoints.web.address=:80",
     "--entrypoints.websecure.address=:443",
     "--entrypoints.websecure.http.tls=true",
     # redirects
     "--entrypoints.web.http.redirections.entrypoint.to=websecure",
     "--entrypoints.web.http.redirections.entrypoint.scheme=https",
     # certificats
     "--entrypoints.websecure.http.tls.certResolver=le",
     "--certificatesresolvers.le.acme.email=tcurdt@foo.com",
     "--certificatesresolvers.le.acme.storage=/acme.json",
     "--certificatesresolvers.le.acme.tlschallenge=true",
     "--certificatesresolvers.le.acme.caserver=https://acme-staging-v02.api.letsencrypt.org/directory",
   ]

and the content of consul looks like this:

{
  "consul": [],
  "mongodb": [],
  "nodejs": [
    "traefik.enable=true",
    "traefik.http.services.nodejs.loadbalancer.server.port=80",
    "traefik.http.routers.nodejs.rule=HostRegexp(`{host:.+}`)",
    "traefik.http.routers.nodejs.tls=true",
    "traefik.http.routers.nodejs.tls.certresolver=le",
    "traefik.http.routers.nodejs.entrypoints=websecure"
  ],
  "nomad": [
    "serf",
    "rpc",
    "http"
  ],
  "nomad-client": [
    "http"
  ],
  "traefik": []
}

IIUC the prefix points to the node in consul - but it does not seem to pick up the service for the catalog. What am I missing?

Turns out this needs refers to the traefik.enable=true and therefor needs to be traefik.

On top of that I had to tag the service with the real port number:

"traefik.http.services.nodejs.loadbalancer.server.port=${NOMAD_PORT_http}",

Now it works!

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.