Web / Traefik Interview questions
How does the ForwardAuth middleware work?
ForwardAuth delegates the authentication decision to an external service: before forwarding the original request to its backend, Traefik first sends a request to the configured auth server and waits for its response.
http: middlewares: my-auth: forwardAuth: address: "https://auth.example.com/verify" authResponseHeaders: - "X-User-Id"
If the auth server responds with a 2xx status, Traefik allows the original request through, optionally copying selected response headers (like a resolved user ID) onto it; any other status causes Traefik to return that response directly to the client and stop the request there.
This pattern is common for centralizing SSO or OAuth logic in one auth service rather than duplicating authentication code in every backend microservice.
More Related questions...