A Traefik token-checker middleware stays useful when it runs on the edge router before the request ever reaches the upstream service, is attached only to the routes that must require a bearer (or similar) header, and fails closed on missing or invalid tokens without leaking upstream timing. Keep public health or webhook paths on a separate router without that middleware, resolve backends by Compose service name on an internal network, and forward Host plus X-Forwarded-For / X-Forwarded-Proto so apps still see the public name after Traefik terminates TLS. Prefer short-circuiting bad tokens at the middleware with a stable 401/403 rather than proxying through and letting each microservice invent its own denial shape.
Ops prove-out after a middleware or label change: call a protected path without a token and expect denial at Traefik, repeat with a valid token and confirm the upstream status, then hit an intentionally exempt path to ensure it never entered the checker. A sudden 404 or 502 on previously healthy routes usually means the middleware was attached too broadly, the service name in the load balancer drifted, or TLS and router Host rules no longer match the name clients dial — fix router attachment and Docker network reachability before tuning token parsing.
Edge Ops
A Traefik token-checker middleware stays useful when it runs on the edge router before the request ever reaches the upstream service, is attached only to the routes that must require a bearer (or similar) header, and fails closed on missing or invalid tokens without leaking upstream timing. Keep public health or webhook paths on a separate router without that middleware, resolve backends by Compose service name on an internal network, and forward Host plus X-Forwarded-For / X-Forwarded-Proto so apps still see the public name after Traefik terminates TLS. Prefer short-circuiting bad tokens at the middleware with a stable 401/403 rather than proxying through and letting each microservice invent its own denial shape.
Ops prove-out after a middleware or label change: call a protected path without a token and expect denial at Traefik, repeat with a valid token and confirm the upstream status, then hit an intentionally exempt path to ensure it never entered the checker. A sudden 404 or 502 on previously healthy routes usually means the middleware was attached too broadly, the service name in the load balancer drifted, or TLS and router Host rules no longer match the name clients dial — fix router attachment and Docker network reachability before tuning token parsing.