Traefik should response with 503 instead of 404 for requests to unregistered consul services

Hello dear Traefik community,
I have a question about my Traefik setup. We are using Traefik as a proxy to reach our services in Hashicorp Nomad. The services register in Consul, which allows Traefik to get the Nomad services and other information like destination IP and port via the Consul Catalog.
We need to make sure that even if an application has a "Dead" status in Nomad, and thus is not registered in Consul, Traefik will respond with a 503 code and not 404.
For this I made exactly the changes described in the Traefik FAQ:

Unfortunately Traefik still refuses to send the requested code and stays with the 404.
Does anyone here maybe have an idea what I have overlooked?
Or is there a better solution than implementing a CatchAll rule in the meantime?

Traefik Configuration:

  • traefik.toml
[respondingTimeouts]
  writeTimeout = "300s"

[entryPoints]
 [entryPoints.http]
  address=":80"
 [entryPoints.http8080]
  address=":8080"

[entryPoints.http.forwardedHeaders]
insecure = true

[entryPoints.http8080.forwardedHeaders]
insecure = true

[entryPoints.traefik]
  address=":8081"

[api]
  dashboard=true
  insecure=true

[providers.consulCatalog]
  refreshInterval="1s"
  prefix="traefik"
  exposedByDefault=false
[providers.consulCatalog.endpoint]
  address="127.0.0.1:8500"
  scheme="http"
[log]
  level="ERROR"

[accessLog]
 [accessLog.fields.headers]
 defaultMode = "keep"
[providers.file]
  filename="dynamic.yaml"
  • dynamic.yaml
http:
  routers:
    catchall:
      # attached only to web entryPoint
      entryPoints:
        - "http"
        - "http8080"
      # catchall rule
      rule: "PathPrefix(`/`)"
      service: unavailable
      # lowest possible priority
      # evaluated when no other router is matched
      priority: 1

  services:
    # Service that will always answer a 503 Service Unavailable response
    unavailable:
      loadBalancer:
        servers: {}

Do you have a providers.file to read the dynamic config file?

yes, it's at the bottom of the traefik.toml

Did you check the log, is it read? I trust more in absolute file names with full path.

Yep... that's it...
Thanks a lot! Well -at least I could learn a lot about traefik :smiley:

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