Traefik v2 router selection issues

Hey everyone,

Has anybody ran into this issue where no router seems to be selected and trafik keeps returning 404s?

What did you do?

Setup traefik with the following configs:

entryPoints:
  web:
    address: ":80"
  web-secure:
    address: ":443"

log:
  level: DEBUG

accessLog: {}

api:
  dashboard: true
  insecure: true

certificatesResolvers:
  le:
    acme:
      email: admin@everflow.io
      storage: acme.json
      tlsChallenge: {}


providers:
  file:
    filename: /etc/traefik/config.yml
http:
  routers:
    tracking:
      entryPoints:
        - web
        - web-secure
      rule: "Host(`tracking.olivierboucher.com`)"
      service: tracking@file
      priority: 1
      tls:
        certResolver: le
        domains:
          - main: "tracking.olivierboucher.com"
  services:
    tracking:
      loadBalancer:
        passHostHeader: true
        servers:
        - url: "http://130.211.40.247"

What did you expect to see?

Be served the content available on http://130.211.40.247

What did you see instead?

A 404 error

Output of traefik version: (What version of Traefik are you using?)

Version:      2.1.1
Codename:     cantal
Go version:   go1.13.5
Built:        2019-12-12T19:01:37Z
OS/Arch:      linux/amd64

What is your environment & configuration (arguments, toml, provider, platform, ...)?

See above

If applicable, please paste the log output in DEBUG level (--log.level=DEBUG switch)

Dec 13 16:58:27 test-traefik systemd[1]: Starting Traefik...
Dec 13 16:58:27 test-traefik traefik[3507]: time="2019-12-13T16:58:27Z" level=info msg="Configuration loaded from file: /etc/traefik/traefik.yml"
Dec 13 16:58:27 test-traefik traefik[3507]: time="2019-12-13T16:58:27Z" level=info msg="Traefik version 2.1.1 built on 2019-12-12T19:01:37Z"
Dec 13 16:58:27 test-traefik traefik[3507]: time="2019-12-13T16:58:27Z" level=debug msg="Static configuration loaded {\"global\":{\"checkNewVersion\":true},\"serversTransport\":{\"maxIdleConnsPerHost\":200},\"entryPoints\":{\"traefik\":{\"address\":\":8080\",\"transport\":{\"lifeCycle\":{\"graceTimeOut\":10000000000},\"respondingTimeouts\":{\"idleTimeout\":180000000000}},\"forwardedHeaders\":{}},\"web\":{\"address\":\":80\",\"transport\":{\"lifeCycle\":{\"graceTimeOut\":10000000000},\"respondingTimeouts\":{\"idleTimeout\":180000000000}},\"forwardedHeaders\":{}},\"web-secure\":{\"address\":\":443\",\"transport\":{\"lifeCycle\":{\"graceTimeOut\":10000000000},\"respondingTimeouts\":{\"idleTimeout\":180000000000}},\"forwardedHeaders\":{}}},\"providers\":{\"providersThrottleDuration\":2000000000,\"file\":{\"watch\":true,\"filename\":\"/etc/traefik/config.yml\"}},\"api\":{\"insecure\":true,\"dashboard\":true},\"log\":{\"level\":\"DEBUG\",\"format\":\"common\"},\"accessLog\":{\"format\":\"common\",\"filters\":{},\"fields\":{\"defaultMode\":\"keep\",\"headers\":{\"defaultMode\":\"drop\"}}},\"certificatesResolvers\":{\"le\":{\"acme\":{\"email\":\"admin@everflow.io\",\"caServer\":\"https://acme-v02.api.letsencrypt.org/directory\",\"storage\":\"acme.json\",\"keyType\":\"RSA4096\",\"tlsChallenge\":{}}}}}"
Dec 13 16:58:27 test-traefik traefik[3507]: time="2019-12-13T16:58:27Z" level=info msg="\nStats collection is disabled.\nHelp us improve Traefik by turning this feature on :)\nMore details on: https://docs.traefik.io/v2.0/contributing/data-collection/\n"
Dec 13 16:58:27 test-traefik traefik[3507]: time="2019-12-13T16:58:27Z" level=info msg="Starting provider aggregator.ProviderAggregator {}"
Dec 13 16:58:27 test-traefik systemd[1]: Started Traefik.
Dec 13 16:58:27 test-traefik traefik[3507]: time="2019-12-13T16:58:27Z" level=debug msg="Start TCP Server" entryPointName=web-secure
Dec 13 16:58:27 test-traefik traefik[3507]: time="2019-12-13T16:58:27Z" level=debug msg="Start TCP Server" entryPointName=web
Dec 13 16:58:27 test-traefik traefik[3507]: time="2019-12-13T16:58:27Z" level=debug msg="Start TCP Server" entryPointName=traefik
Dec 13 16:58:27 test-traefik traefik[3507]: time="2019-12-13T16:58:27Z" level=info msg="Starting provider *file.Provider {\"watch\":true,\"filename\":\"/etc/traefik/config.yml\"}"
Dec 13 16:58:27 test-traefik traefik[3507]: time="2019-12-13T16:58:27Z" level=info msg="Watchdog activated with timer duration 500ms"
Dec 13 16:58:27 test-traefik traefik[3507]: time="2019-12-13T16:58:27Z" level=info msg="Starting provider *acme.Provider {\"email\":\"admin@everflow.io\",\"caServer\":\"https://acme-v02.api.letsencrypt.org/directory\",\"storage\":\"acme.json\",\"keyType\":\"RSA4096\",\"tlsChallenge\":{},\"ResolverName\":\"le\",\"store\":{},\"ChallengeStore\":{}}"
Dec 13 16:58:27 test-traefik traefik[3507]: time="2019-12-13T16:58:27Z" level=info msg="Testing certificate renew..." providerName=le.acme
Dec 13 16:58:27 test-traefik traefik[3507]: time="2019-12-13T16:58:27Z" level=info msg="Starting provider *traefik.Provider {}"
Dec 13 16:58:27 test-traefik traefik[3507]: time="2019-12-13T16:58:27Z" level=debug msg="Configuration received from provider file: {\"http\":{\"routers\":{\"tracking\":{\"entryPoints\":[\"web\",\"web-secure\"],\"service\":\"tracking@file\",\"rule\":\"Host(`tracking.olivierboucher.com`)\",\"priority\":1,\"tls\":{\"certResolver\":\"le\",\"domains\":[{\"main\":\"tracking.olivierboucher.com\"}]}}},\"services\":{\"tracking\":{\"loadBalancer\":{\"servers\":[{\"url\":\"http://130.211.40.247\"}],\"passHostHeader\":true}}}},\"tcp\":{},\"tls\":{}}" providerName=file
Dec 13 16:58:27 test-traefik traefik[3507]: time="2019-12-13T16:58:27Z" level=debug msg="Configuration received from provider le.acme: {\"http\":{},\"tls\":{}}" providerName=le.acme
Dec 13 16:58:27 test-traefik traefik[3507]: time="2019-12-13T16:58:27Z" level=debug msg="Configuration received from provider internal: {\"http\":{\"routers\":{\"api\":{\"entryPoints\":[\"traefik\"],\"service\":\"api@internal\",\"rule\":\"PathPrefix(`/api`)\",\"priority\":2147483646},\"dashboard\":{\"entryPoints\":[\"traefik\"],\"middlewares\":[\"dashboard_redirect@internal\",\"dashboard_stripprefix@internal\"],\"service\":\"dashboard@internal\",\"rule\":\"PathPrefix(`/`)\",\"priority\":2147483645}},\"middlewares\":{\"dashboard_redirect\":{\"redirectRegex\":{\"regex\":\"^(http:\\\\/\\\\/[^:]+(:\\\\d+)?)/$\",\"replacement\":\"${1}/dashboard/\",\"permanent\":true}},\"dashboard_stripprefix\":{\"stripPrefix\":{\"prefixes\":[\"/dashboard/\",\"/dashboard\"]}}},\"services\":{\"api\":{},\"dashboard\":{}}},\"tcp\":{},\"tls\":{}}" providerName=internal
Dec 13 16:58:27 test-traefik traefik[3507]: time="2019-12-13T16:58:27Z" level=debug msg="Creating middleware" entryPointName=web middlewareName=pipelining middlewareType=Pipelining routerName=tracking@file serviceName=tracking@file
Dec 13 16:58:27 test-traefik traefik[3507]: time="2019-12-13T16:58:27Z" level=debug msg="Creating load-balancer" routerName=tracking@file serviceName=tracking@file entryPointName=web
Dec 13 16:58:27 test-traefik traefik[3507]: time="2019-12-13T16:58:27Z" level=debug msg="Creating server 0 http://130.211.40.247" serviceName=tracking@file serverName=0 entryPointName=web routerName=tracking@file
Dec 13 16:58:27 test-traefik traefik[3507]: time="2019-12-13T16:58:27Z" level=debug msg="Added outgoing tracing middleware tracking@file" middlewareType=TracingForwarder entryPointName=web routerName=tracking@file middlewareName=tracing
Dec 13 16:58:27 test-traefik traefik[3507]: time="2019-12-13T16:58:27Z" level=debug msg="Creating middleware" middlewareName=traefik-internal-recovery middlewareType=Recovery entryPointName=web
Dec 13 16:58:27 test-traefik traefik[3507]: time="2019-12-13T16:58:27Z" level=debug msg="Creating middleware" middlewareType=Recovery entryPointName=web-secure middlewareName=traefik-internal-recovery
Dec 13 16:58:27 test-traefik traefik[3507]: time="2019-12-13T16:58:27Z" level=debug msg="No default certificate, generating one"
Dec 13 16:58:27 test-traefik traefik[3507]: time="2019-12-13T16:58:27Z" level=debug msg="Looking for provided certificate(s) to validate [\"tracking.olivierboucher.com\"]..." providerName=le.acme
Dec 13 16:58:27 test-traefik traefik[3507]: time="2019-12-13T16:58:27Z" level=debug msg="Adding certificate for domain(s) tracking.olivierboucher.com"
Dec 13 16:58:27 test-traefik traefik[3507]: time="2019-12-13T16:58:27Z" level=debug msg="No default certificate, generating one"
Dec 13 16:58:28 test-traefik traefik[3507]: time="2019-12-13T16:58:28Z" level=debug msg="Creating middleware" entryPointName=web-secure routerName=tracking@file serviceName=tracking@file middlewareName=pipelining middlewareType=Pipelining
Dec 13 16:58:28 test-traefik traefik[3507]: time="2019-12-13T16:58:28Z" level=debug msg="Creating load-balancer" routerName=tracking@file serviceName=tracking@file entryPointName=web-secure
Dec 13 16:58:28 test-traefik traefik[3507]: time="2019-12-13T16:58:28Z" level=debug msg="Creating server 0 http://130.211.40.247" entryPointName=web-secure routerName=tracking@file serviceName=tracking@file serverName=0
Dec 13 16:58:28 test-traefik traefik[3507]: time="2019-12-13T16:58:28Z" level=debug msg="Added outgoing tracing middleware tracking@file" entryPointName=web-secure routerName=tracking@file middlewareName=tracing middlewareType=TracingForwarder
Dec 13 16:58:28 test-traefik traefik[3507]: time="2019-12-13T16:58:28Z" level=debug msg="Creating middleware" entryPointName=web-secure middlewareName=traefik-internal-recovery middlewareType=Recovery
Dec 13 16:58:28 test-traefik traefik[3507]: time="2019-12-13T16:58:28Z" level=debug msg="Creating middleware" entryPointName=web middlewareName=traefik-internal-recovery middlewareType=Recovery
Dec 13 16:58:28 test-traefik traefik[3507]: time="2019-12-13T16:58:28Z" level=debug msg="No ACME certificate generation required for domains [\"tracking.olivierboucher.com\"]." providerName=le.acme
Dec 13 16:58:28 test-traefik traefik[3507]: time="2019-12-13T16:58:28Z" level=debug msg="Looking for provided certificate(s) to validate [\"tracking.olivierboucher.com\"]..." providerName=le.acme
Dec 13 16:58:28 test-traefik traefik[3507]: time="2019-12-13T16:58:28Z" level=debug msg="Adding certificate for domain(s) tracking.olivierboucher.com"
Dec 13 16:58:28 test-traefik traefik[3507]: time="2019-12-13T16:58:28Z" level=debug msg="No default certificate, generating one"
Dec 13 16:58:28 test-traefik traefik[3507]: time="2019-12-13T16:58:28Z" level=debug msg="No ACME certificate generation required for domains [\"tracking.olivierboucher.com\"]." providerName=le.acme
Dec 13 16:58:28 test-traefik traefik[3507]: time="2019-12-13T16:58:28Z" level=debug msg="Added outgoing tracing middleware dashboard@internal" middlewareType=TracingForwarder routerName=dashboard@internal entryPointName=traefik middlewareName=tracing
Dec 13 16:58:28 test-traefik traefik[3507]: time="2019-12-13T16:58:28Z" level=debug msg="Creating middleware" routerName=dashboard@internal entryPointName=traefik middlewareName=dashboard_stripprefix@internal middlewareType=StripPrefix
Dec 13 16:58:28 test-traefik traefik[3507]: time="2019-12-13T16:58:28Z" level=debug msg="Adding tracing to middleware" entryPointName=traefik routerName=dashboard@internal middlewareName=dashboard_stripprefix@internal
Dec 13 16:58:28 test-traefik traefik[3507]: time="2019-12-13T16:58:28Z" level=debug msg="Creating middleware" routerName=dashboard@internal entryPointName=traefik middlewareName=dashboard_redirect@internal middlewareType=RedirectRegex
Dec 13 16:58:28 test-traefik traefik[3507]: time="2019-12-13T16:58:28Z" level=debug msg="Setting up redirection from ^(http:\\/\\/[^:]+(:\\d+)?)/$ to ${1}/dashboard/" entryPointName=traefik middlewareName=dashboard_redirect@internal middlewareType=RedirectRegex routerName=dashboard@internal
Dec 13 16:58:28 test-traefik traefik[3507]: time="2019-12-13T16:58:28Z" level=debug msg="Adding tracing to middleware" entryPointName=traefik routerName=dashboard@internal middlewareName=dashboard_redirect@internal
Dec 13 16:58:28 test-traefik traefik[3507]: time="2019-12-13T16:58:28Z" level=debug msg="Added outgoing tracing middleware api@internal" middlewareName=tracing middlewareType=TracingForwarder entryPointName=traefik routerName=api@internal
Dec 13 16:58:28 test-traefik traefik[3507]: time="2019-12-13T16:58:28Z" level=debug msg="Creating middleware" middlewareName=traefik-internal-recovery middlewareType=Recovery entryPointName=traefik
Dec 13 16:58:28 test-traefik traefik[3507]: time="2019-12-13T16:58:28Z" level=debug msg="Creating middleware" middlewareType=Pipelining middlewareName=pipelining routerName=tracking@file entryPointName=web serviceName=tracking@file
Dec 13 16:58:28 test-traefik traefik[3507]: time="2019-12-13T16:58:28Z" level=debug msg="Creating load-balancer" serviceName=tracking@file routerName=tracking@file entryPointName=web
Dec 13 16:58:28 test-traefik traefik[3507]: time="2019-12-13T16:58:28Z" level=debug msg="Creating server 0 http://130.211.40.247" routerName=tracking@file entryPointName=web serviceName=tracking@file serverName=0
Dec 13 16:58:28 test-traefik traefik[3507]: time="2019-12-13T16:58:28Z" level=debug msg="Added outgoing tracing middleware tracking@file" entryPointName=web routerName=tracking@file middlewareName=tracing middlewareType=TracingForwarder
Dec 13 16:58:28 test-traefik traefik[3507]: time="2019-12-13T16:58:28Z" level=debug msg="Creating middleware" entryPointName=web middlewareName=traefik-internal-recovery middlewareType=Recovery
Dec 13 16:58:28 test-traefik traefik[3507]: time="2019-12-13T16:58:28Z" level=debug msg="Creating middleware" entryPointName=web-secure middlewareName=traefik-internal-recovery middlewareType=Recovery
Dec 13 16:58:28 test-traefik traefik[3507]: time="2019-12-13T16:58:28Z" level=debug msg="Looking for provided certificate(s) to validate [\"tracking.olivierboucher.com\"]..." providerName=le.acme
Dec 13 16:58:28 test-traefik traefik[3507]: time="2019-12-13T16:58:28Z" level=debug msg="No ACME certificate generation required for domains [\"tracking.olivierboucher.com\"]." providerName=le.acme
Dec 13 16:58:30 test-traefik traefik[3507]: 173.176.21.125 - - [13/Dec/2019:16:58:30 +0000] "GET /api/overview HTTP/1.1" 200 332 "-" "-" 1 "api@internal" - 0ms
Dec 13 16:58:35 test-traefik traefik[3507]: 173.176.21.125 - - [13/Dec/2019:16:58:35 +0000] "GET /api/overview HTTP/1.1" 200 332 "-" "-" 2 "api@internal" - 0ms
Dec 13 16:58:39 test-traefik traefik[3507]: 173.176.21.125 - - [13/Dec/2019:16:58:39 +0000] "GET /api/overview HTTP/1.1" 200 332 "-" "-" 3 "api@internal" - 0ms
Dec 13 16:58:39 test-traefik traefik[3507]: 173.176.21.125 - - [13/Dec/2019:16:58:39 +0000] "GET / HTTP/1.1" - - "-" "-" 4 - - 0ms

It seems like traefik is unable to select a proper router. I also tried different rules (like a match all regex or / path prefix) but all of them still continued to give the 404.

Hey :slight_smile:

That's actually a false "assumption" lets say. You have set the service tracking to use the url http://130.211.40.247 as a backend.

You should see the page, once you try to hit tracking.olivierboucher.com as this is the rule on your router :slight_smile:

Sorry if that was not clear but that's what I am doing... This config is live at the moment, you can hit tracking.olivierboucher.com and see the 404

Hello,

sorry, I was on vacation :slight_smile: It currently works as intended. You did select the router to be a TLS Router which resolves certificiates over Lets Encrypt.

Thus, with that configuration, you need to hit your page with https://tracking.olivierboucher.com .

If you want to have automatic redirection, you will need to create a seperate router which does the job.