authentik forward auth with Traefik

Protect applications that cannot speak OIDC or SAML by routing Traefik's forwardAuth middleware through the authentik proxy outpost, with the header and mode choices made up front.

On this page

When authentik forward auth with Traefik fits your applications

Forward auth with the authentik proxy outpost is the right pattern when an application has no OIDC or SAML support and sits behind Traefik, so you cannot make it a relying party of authentik directly. Traefik's forwardAuth middleware sends each incoming request to the authentik outpost before it reaches the application. The outpost checks for a valid authentik session, redirects anonymous users to the sign-in flow, and only then lets the request through with identity headers attached. This fits legacy web apps, internal dashboards and vendor tools that accept a trusted header or have no login of their own, and it fits teams that already run Traefik as their edge router.

The application itself does not change. Authentication happens at the proxy, and the app receives the request with headers that identify the user and the application. That model has limits you should plan for. The app must not be reachable except through Traefik, or a client can send the headers directly and bypass the check. Only the headers the outpost sets should be trusted, and any app that reads them must validate that origin. Authorization is only as fine-grained as the policies bound to each provider, and API clients that cannot follow a redirect to a login page may need a separate path. Confirm which header names and session behavior your application expects before you commit to the pattern.

Before you build, decide three things with the application owner: whether the app can be locked to the proxy network, whether it needs per-user identity or just a gate, and whether one provider per application or one domain-level provider fits your access model. Check the current Traefik and authentik documentation for your versions, since the outpost setup and header behavior are version-specific. Also confirm how your team will test that a direct request to the application is refused, because that negative test is what proves the proxy is actually in control.

Docker Compose labels or Kubernetes ingress routes

In Compose, the forwardAuth middleware is declared with Traefik labels and the application's router references it by name. Traefik sends each request to the authentik outpost endpoint before forwarding it, so Traefik and the authentik server must share a Docker network that the application can also reach. Every label set below needs to be checked against the Traefik and authentik versions you run.

  • Middleware definition: Declare the middleware once with labels such as traefik.http.middlewares.authentik.forwardauth.address, pointing at the outpost endpoint on the authentik server container.
  • Router attachment: Add traefik.http.routers.<app>.middlewares=authentik to the application's container so each request is checked before it reaches the application.
  • Response headers: List the identity headers the outpost returns in the auth response header setting so the application receives the signed-in user. Confirm the header names against the outpost documentation for your release.
  • Forwarded headers: Only trust forwarded host and protocol headers when Traefik is the sole entry point to the application, or a client could spoof them.
  • Network membership: Place Traefik, the authentik server and the application on a shared network, and confirm that the service name in the forwardAuth address resolves from Traefik's container.

Before you move on, test an unauthenticated request to the application, which should redirect to the login flow, and then a signed-in request, which should reach the application with the expected headers.

Single-application versus domain-level mode compared

This table compares one authentik proxy provider per application with one provider covering a parent domain for Traefik forward auth. Read each row as a decision point: how the provider is set up, how access policy is applied, and which cookie and prompt behavior to verify before you choose.

OptionSingle-application providerDomain-level provider
How it is configuredOne proxy provider and one application per hostname, with the external host set to that application's URLOne proxy provider in domain mode covering the parent domain, with applications for each hostname under it
Per-application policyEach application gets its own bindings, groups and policies, so access rules can differ host by hostPolicies bind at the application level, but all hosts share one session and one provider, so differences need careful binding
Cookie domain behaviorCookie scope follows the single hostname; confirm the cookie domain setting for your versionCookie scope spans sibling subdomains under the parent domain; confirm the cookie domain value and any shared-session effects
Authorization prompt behaviorA user is prompted for authorization for that one application; confirm how the prompt appears in your versionA single sign-on session can cover several applications, so users may see fewer prompts across sibling hosts; confirm in a test
Traefik routing effortEach service needs its own forwardAuth middleware reference and an auth route per hostOne middleware definition can be reused across services on the domain, reducing repeated labels or ingress annotations
Blast radius of misconfigurationAn error affects one application's access pathA wrong domain-level setting can expose or block every application under the parent domain
Operational overheadMore providers and applications to create, review and rotate as the estate growsFewer providers to manage, but the parent domain and cookie design must be documented and reviewed
When it fitsApplications with different audiences, sensitivity levels or ownership, or a small number of protected hostsMany internal applications under one domain that share one user population and one access model

Setting up forwardAuth with the authentik proxy outpost

This sequence places authentik in front of an application served by Traefik, so unauthenticated requests redirect to sign-in and only permitted users reach the backend with identity headers. Each step ends with a check you can record before moving on.

  1. Confirm the authentik version and release line

    Check which authentik release your deployment runs and whether that release line still receives security fixes. The security policy lists 2026.5.x and 2026.8.x as supported, and the project announces security releases at least 24 hours in advance. The platform team reads the installed version in the admin interface, compares it with the supported lines, and schedules any upgrade before new routes are added. Done when the version and its support status are recorded in the change ticket.

  2. Create the proxy provider and application

    In the authentik admin interface, create a proxy provider for the application's external URL and choose single-application or domain-level mode, since that choice sets cookie scope and how many providers you maintain. Create an application that uses the provider, then bind the groups or policies allowed to reach it. Confirm the external hostname matches the host rule you will write in Traefik. Done when the provider lists the expected external host and the policy binding shows only the intended groups.

  3. Deploy or confirm the proxy outpost

    Confirm which outpost serves the provider: the embedded outpost in the authentik server container or a standalone proxy outpost. On Docker, use the Docker integration or a manual Compose service that runs with an outpost token. On Kubernetes, use the built-in integration or your own manifests. Place the outpost on a network Traefik can reach and assign the provider to it. Done when the outpost reports as connected to the authentik server and the provider shows that outpost as assigned.

  4. Add the forwardAuth middleware in Traefik

    Define a Traefik forwardAuth middleware that sends each request to the outpost's address for an authentication decision. Set the address to the outpost endpoint documented for your authentik version, and list in authResponseHeaders the identity headers the application needs, such as user name, email and groups. Confirm the exact header names against the authentik integration guide for your release. Enable trustForwardHeader only after verifying that forwarded headers come from Traefik. Done when Traefik loads the middleware without errors in its dashboard or logs.

  5. Attach the middleware to the router

    Attach the middleware to the router for the application. With Docker labels, add the middleware reference to the router's middlewares label, using the provider suffix that matches where the middleware is defined. On Kubernetes, reference the Middleware resource from the IngressRoute or the Traefik ingress annotations, in the namespace Traefik expects. The middleware name must match exactly in both places. Done when the Traefik dashboard shows the router with the forwardAuth middleware in its chain.

  6. Verify redirects, sign-in and header delivery

    Test three cases with an illustrative test user in and out of the allowed group. First, an unauthenticated request to the application should redirect to the authentik sign-in page. Second, a signed-in user in the allowed group should reach the application. Third, a user outside the group should be denied. Then confirm the identity headers arrive at the backend, using application logs or a temporary echo service. Done when all three cases behave as expected and the headers match the list in the middleware.

Which identity headers reach the application

Traefik's forwardAuth middleware does not pass identity to the application on its own. After the outpost answers an authentication check, Traefik copies only the response headers you list in the middleware's authResponseHeaders setting onto the request it forwards upstream. Anything not listed is dropped, so the first decision is to keep that list as short as the application needs. Typically this means the user identifier and the groups or email claims the application actually reads. Confirm the exact header names against the outpost version you run before writing them into the application configuration, because the names authentik sets for forward auth have changed across releases and an application that reads the wrong header will fail in ways that look like login problems.

The application should trust only the headers that Traefik sets after a successful check. Most applications accept any header a client sends, so a visitor who reaches the application directly could type in an identity header and be signed in as someone else. Treat the proxy as the only path in: restrict the application's network so its port is reachable only from the Traefik container or host, and remove any published port that bypasses the router. Also make sure Traefik strips client-supplied copies of the identity headers before forwardAuth runs. Test this by sending a request straight to the application with a forged header and confirming it is rejected or ignored.

Plan a verification step for each header and each route. For a sample request through a protected hostname, check that the application sees the expected user and groups, that a user outside the authorized group receives the authentik login or access denied response, and that a forged header from outside the proxy has no effect. Record the authentik version, the Traefik version and the middleware definition with the test results, so a later upgrade of either component can be re-checked against the same expectations. If your application reads headers that authentik does not supply by default, ask the authentik documentation or your own configuration review how to add a custom header before relying on it in production.

Security risks in trusting proxy-set identity headers

Forward auth works because Traefik trusts the outpost's answer and passes identity headers to the application. Every card below is a place where that trust can fail, so each one names a check to run before the route goes live.

Direct access bypasses the proxy

If the application container or its port is reachable without passing through Traefik, anyone on that network can send a request with forged X-authentik-username and group headers and the app will accept them. Check that the service has no published host port, sits on a Docker network only Traefik can reach, and that Kubernetes NetworkPolicies allow ingress only from the Traefik pods. Test this from outside the proxy path, not from the browser.

Cookie domain and session scope

authentik's session cookie scope decides which hostnames can present a signed-in session. In domain-level mode, a cookie set for a parent domain reaches every subdomain, including ones you do not control or have not hardened. Confirm the cookie domain, list every hostname it covers, and decide whether a compromised sibling application could reuse the session.

TLS between Traefik and the outpost

Traefik calls the outpost's forward auth endpoint on every request, and that call carries session data and returns the identity headers. Where the outpost sits on another host or network segment, the hop should use TLS with certificates Traefik verifies, or stay on a private network with restricted access. Document which path is used and who can reach the outpost port.

Outpost token handling

Outposts authenticate to authentik with a token. A leaked token lets someone impersonate an outpost and register itself with the server. Store the token in your secret manager or Compose secrets rather than in labels or committed files, rotate it when people with access change roles, and confirm which outposts hold it.

Session and access logging

Forward auth decisions are made outside the application, so the application log will not show who was allowed in. Forward Traefik access logs and authentik's event logs to your central store, and confirm they record the user, the host, and the allow or deny outcome. Without these records, a bypass attempt or a stale session is hard to reconstruct.

Supported release lines

The authentik security policy lists which versions receive security fixes, and the project announces security releases at least 24 hours in advance. Keep both the authentik server and any standalone outpost on a supported line, and match their versions. Subscribe to release notifications and plan a maintenance window so a fix can be applied within that notice period.

Questions teams ask before forwardAuth with Traefik

Is authentik free to use for protecting applications behind Traefik?

Yes, the Open Source edition of authentik is free, and the forward auth pattern described on this page works with it. The project's license puts most of the code under the MIT license, while code in the authentik/enterprise/ directory falls under a separate enterprise license. The pricing page lists Enterprise at $5 per user per month billed annually, plus $0.02 per external user per month, and Enterprise Plus starting at $20k annually. Enterprise adds Google Workspace and Microsoft Entra ID integrations, mTLS client certificate authentication, enhanced audit logging and ticket-based support for subscriptions over $1k. Confirm with the authentik team which edition your user model and integrations require before you budget, because a Traefik forward auth setup itself does not depend on those features.

How much effort does a Traefik forwardAuth setup take, and what drives it?

The core change is small: a forwardAuth middleware on Traefik that calls the authentik outpost, plus labels or ingress routes that attach the middleware to each protected service. The effort grows with the number of applications, how many distinct hostnames and paths you expose, how many header values each upstream expects, and how many policy decisions you need per application. Environment choices matter too. Docker Compose suits test setups and small-scale production, and the authentik documentation lists at least 2 CPU cores and 2 GB of RAM for that host. Kubernetes installs use Helm, and the bundled PostgreSQL is intended for demonstration and test environments, so a production cluster needs a separately managed database. Ask a partner for a written scope that lists each application, its route type and its header needs before agreeing on duration.

Can an in-house team set up authentik forward auth with Traefik by itself?

A team with working knowledge of Traefik, Docker or Kubernetes, and a reverse proxy can usually build a first protected route with the official documentation. The harder part is the surrounding work: deciding which applications should sit behind the outpost, testing login redirects and cookies for each hostname, verifying that identity headers reach the backend without being spoofed, and building backups, monitoring and an upgrade routine for authentik and its PostgreSQL database. If your team lacks capacity in one of these areas, a fixed-scope engagement can cover planning, build, hardening and handover in writing. Either way, assign a named owner for the outpost, because a misconfigured middleware can lock users out of several applications at once.

What does the work need from our team before the build starts?

The build needs four inputs. First, an application inventory listing each service, its hostname, its path prefixes and whether it already has its own login. Second, DNS records for every hostname and a plan for the authentik hostname that users will reach during sign-in. Third, TLS certificates that Traefik can manage for those names, including the cookie domain for any domain-level setup. Fourth, a header requirements list: which user, group or email values each application reads, and whether it trusts headers at all. Owners of each application should also confirm who may access it and which groups map to which roles. Teams that deliver this list early usually see fewer rework cycles during testing.

How does domain-level forward auth change the cost of a later change?

In single-application mode, each protected service has its own provider and its own policy, so adding or removing a service means editing one provider and one router. In domain-level mode, one provider covers a parent domain and its cookies apply across every subdomain under it. That reduces setup work when many applications share a domain, but a change to the shared cookie domain, the authorization prompt or the policy affects every application under it at once. Plan a test environment that mirrors the production domain layout before changing the mode. Ask any partner to price changes to the mode separately, because moving from one model to the other usually means re-testing each application's login and logout paths.

How do authentik upgrades affect the outpost behind Traefik?

The outpost must stay compatible with the authentik server it talks to, so upgrades need to cover both components together. Check the security policy first: the project lists 2026.5.x and 2026.8.x as the supported versions receiving security fixes, and it announces security releases at least 24 hours in advance. Read the release notes for each version between your current and target release, since the 2025.10 notes, for example, removed Redis and warned of roughly 50% more PostgreSQL connections after upgrading. Test the outpost image tag, the middleware labels or ingress annotations and the login and logout flow for one application before rolling the change across the rest. Confirm the upgrade sequence with the authentik team, because skipping a required intermediate version can block the update.

Running forward auth after go-live

After go-live, the first thing to watch is whether the Traefik forwardAuth middleware still gets a fast, correct answer from the authentik outpost. Monitor the path end to end: request latency and error rates on the outpost endpoint that the middleware calls, Traefik access logs showing 401 and 403 responses on protected routes, and authentication failures on the authentik side. A sudden rise in 500 responses from the middleware usually means the outpost cannot reach the authentik server or its configuration has drifted, while a rise in redirects on API clients often points to a missing bypass or a header mismatch. Confirm which metrics and log streams your authentik version exposes before you build dashboards, because the exact names and endpoints should come from the documentation for your release rather than from memory.

Upgrades need a deliberate rule for the outpost and the server. The outpost that Traefik talks to should run the same authentik version as the server, so schedule the server and outpost upgrades together and test the middleware on a staging stack first. Read the upgrade notes for each release in the sequence you need to follow, since authentik's upgrade guidance expects you to move through versions in order. Pin image tags in your Compose files or Helm values instead of using floating tags, and record which outpost image each Traefik-protected application uses so a rollback can restore a matching pair. Security releases are announced at least 24 hours in advance, and the security policy lists the supported version lines, so check that your running line still appears there at each review.

The 2025.10 release notes state that authentik no longer uses Redis, moving caching, tasks, sessions and WebSocket functions to PostgreSQL, and they warn of roughly 50% more PostgreSQL connections after upgrading. For a forward auth deployment this matters because every protected request depends on the session and outpost path. Before upgrading across that release, raise the PostgreSQL connection limit or add pooling, watch active connection counts and errors during the first hours, and remove any Redis dependencies from your own runbooks and monitoring. Lockout recovery should be tested before it is needed: in a staging environment, lock out a test user, confirm which administrator account or recovery flow restores access, and confirm that an emergency bypass route for the admin interface does not depend on the forward auth middleware it protects.

How DeployOpen scopes and delivers forward auth

DeployOpen plans, implements, hardens, documents and supports self-hosted open-source platforms inside your own infrastructure, including authentik forward auth in front of Traefik. Engagements are fixed-scope, with the scope, deliverables and timeline agreed in writing before work starts.

How we scope

  • Inventory which applications sit behind Traefik and which can accept a forwarded identity header
  • Decide per application whether a single-application provider or a domain-level provider fits your access model
  • Agree in writing the Traefik routers, middlewares, cookie domains and authentik providers that are in scope

How we build

  • Deploy the authentik server, worker and an outpost in your Docker or Kubernetes environment, with the outpost path routed through Traefik
  • Configure the forwardAuth middleware and the identity headers passed to each upstream application
  • Test sign-in, sign-out, redirects and access denial for each protected route before handover

How we hand over

  • Document each router, middleware, provider and policy, with the configuration files and their locations
  • Provide a runbook for adding an application, rotating outpost tokens and recovering from a lockout
  • Walk your platform and security teams through the test results and the open items agreed in scope

How we support

  • Plan authentik version upgrades around the sequential upgrade rule and the outpost version that must match the server
  • Offer ongoing support, upgrades and continuous testing as a retainer, priced from the written scope
  • Confirm with your team which authentik release line receives security fixes before setting the upgrade cadence

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.