Protecting internal apps with OAuth2 Proxy and Zitadel: what the pattern does
Use this pattern when an internal app has no native single sign-on and must only be reachable after a Zitadel login. OAuth2 Proxy runs as a reverse proxy in front of the app and authenticates users against a Zitadel web application using the authorization code flow with BASIC client authentication, which is the method Zitadel's OAuth2 Proxy example recommends. OAuth2 Proxy is an MIT-licensed reverse proxy and a Cloud Native Computing Foundation Sandbox project, so the component itself carries no license fee and is governed by a community project rather than a single vendor.
The proxy checks that each request carries a valid session, and if it does not, it redirects the browser to Zitadel for sign-in. After login it forwards identity to the upstream app as headers such as X-Forwarded-User, X-Forwarded-Groups and X-Forwarded-Email, and it can pass the access token or ID token if the app needs them. The app itself is not changed: it trusts the headers only because the proxy is the sole route to it, so the network design must make sure nothing can reach the app directly. Role checks are a second decision. Zitadel's roles and grants are carried in tokens, and you must confirm which claim OAuth2 Proxy exposes to the app and whether the app or the proxy enforces each role.
Before you build, confirm three things with your own environment: which apps need group-based access, whether those groups or roles reach the proxy as claims, and how sessions will be stored. By default OAuth2 Proxy keeps sessions in encrypted cookies that need a cookie secret, and Redis is the alternative. Cookie sessions cannot be locked, so concurrent token refreshes can force a re-login, which affects apps that make many parallel requests. The OAuth2 Proxy session storage documentation describes the trade-off in detail.
What you need before configuring OAuth2 Proxy and Zitadel
Protecting an internal app with OAuth2 Proxy and Zitadel depends on a few components that must exist before any configuration starts. The cards below cover the identity side, the proxy release, session storage, network names and the people who own the app's roles, since each one changes how the setup is built and tested.
Self-hosted Zitadel with PostgreSQL
Zitadel stores its data in PostgreSQL 14 through 18, so the database version must be chosen inside that range before installation. Confirm which deployment method you will use (binaries, Docker Compose or Kubernetes) and who operates the database backups. The OAuth2 Proxy setup assumes a working Zitadel instance that you can log into as an administrator.
- Supported PostgreSQL versions
- 14 to 18
Organization and project for the apps
Decide which Zitadel organization will own the internal apps and create a project to group the OAuth2 Proxy application, its roles and its grants. Users who sign in through the proxy must belong to this organization, so check whether your workforce users already exist there or will be created or federated. Naming this boundary early keeps role checks simple later.
Zitadel organizations docsOAuth2 Proxy release to deploy
Pin one OAuth2 Proxy release in your deployment manifests rather than tracking a moving image tag. The current release at the time of writing is v7.15.5, published on October 1, 2026, so confirm it on the GitHub releases page and review its changelog for configuration changes before deploying. Record the version in your change records so upgrades can be planned.
OAuth2 Proxy releasesCookie secret or Redis sessions
Choose where session state lives before you deploy. Encrypted cookie sessions need a cookie secret and hold no server state, but they cannot be locked, so concurrent token refreshes can force a fresh login. Redis, including Sentinel or Cluster, keeps only a ticket in the cookie and suits users who open many tabs or sessions at once. Ask who will rotate the secret and who will run Redis.
Session storage docsDNS and TLS for both hostnames
You need two certificate-backed hostnames: one for the protected app behind the proxy and one for the Zitadel domain that the proxy calls for login and token exchange. Confirm that the proxy can reach the Zitadel issuer URL over TLS from its network, and that browsers can reach the proxy hostname. Mismatched hostnames are a common cause of redirect failures, so write both names down before creating any application.
Owner for the app role model
Name one person who owns the roles the upstream app expects, such as which Zitadel roles grant admin or read access. OAuth2 Proxy forwards user, group and email headers, but it does not decide what a user may do inside the app, so the app or a policy layer must check them. Ask this owner to confirm the exact claim or header names the app reads before go-live.
How to configure the Zitadel web application for OAuth2 Proxy
This sequence creates a Zitadel web application that uses the authorization code flow, wires its credentials into OAuth2 Proxy, and sets up sessions and identity headers so an internal app receives verified user details. The result is a tested login path that gates the app before any traffic reaches it.
Create the web application in a Zitadel project
An administrator in the organization that owns the internal app opens the project in the Zitadel console and adds a new application of type Web. Select the authorization code flow and set the authentication method to BASIC, which is the combination Zitadel recommends for OAuth2 Proxy. Record the issuer URL of your Zitadel instance, because OAuth2 Proxy will use it for discovery. The step is done when the application appears in the project with the expected type and method and the console shows its client ID and secret.
Register the OAuth2 Proxy callback redirect URL
In the same application, add the redirect URL that OAuth2 Proxy serves, which is the public address of the proxy followed by the /oauth2/callback path. The value must match the proxy's external hostname and scheme exactly, because Zitadel rejects a login that returns to an unregistered address. Add a post-logout URL only if your proxy design uses one. The step is done when a test request to the callback path on the proxy's public hostname is accepted by Zitadel during the login redirect, with no mismatch error.
Store the client ID and secret in a secret store
Copy the client ID and client secret from the Zitadel application and place them in your organization's secret store, not in a shared configuration file or a source repository. Grant read access only to the service that runs OAuth2 Proxy. Plan how the secret will be rotated, since changing it in Zitadel requires updating the proxy configuration at the same time. The step is done when the proxy's deployment pulls both values from the secret store at startup and no plaintext copy remains in version control.
Set the OIDC issuer and provider settings
Configure OAuth2 Proxy with the generic OIDC provider type, the Zitadel issuer URL, the client ID and the secret pulled from the store. Set the scope to include the standard OpenID scopes that your upstream app needs, and confirm that the email and profile claims you plan to forward are present in Zitadel's responses for a test user. Check the proxy's startup log for successful OIDC discovery against the issuer. The step is done when the proxy starts without discovery errors and reports the Zitadel provider as active.
Configure the cookie secret or Redis session store
Choose how sessions are held. The default stores encrypted sessions in client-side cookies, which requires a cookie secret of the length and encoding the proxy documentation specifies, generated from a cryptographic random source and kept in the secret store. Redis, including Redis Sentinel or Redis Cluster, keeps only a ticket in the cookie and is better suited when token refreshes run concurrently, because cookie sessions cannot be locked. Confirm the choice with your platform team before go-live. The step is done when a login creates a session that survives a proxy restart if you chose Redis, or that decrypts correctly across all proxy replicas if you chose cookies.
Enable identity headers for the upstream app
Turn on the set-xauthrequest option if the proxy runs in front of nginx with auth_request, or configure the proxy to pass identity headers directly to the upstream. Headers include X-Forwarded-User, X-Forwarded-Groups and X-Forwarded-Email, and you can choose whether to pass the access token or ID token. Make the upstream app trust these headers only when requests arrive through the proxy, and strip any client-supplied copies at the edge. The step is done when the upstream app logs the expected user and email values for a signed-in test user and rejects a request that carries a forged header sent directly to it.
Test a login and a role check
Sign in through the protected hostname with a test user from each relevant Zitadel role or group. Confirm that an unauthenticated request redirects to Zitadel, that the callback returns the user to the requested path, and that the upstream receives the subject and group headers you expect. Then sign in as a user without the required role and confirm that access is denied at the level you designed, whether in the proxy or the app. Record the results so that the test can be repeated after upgrades. The step is done when both the allowed and denied paths behave as specified in your access design.
Mapping Zitadel claims and roles to OAuth2 Proxy headers and upstream app roles
This table maps each identity signal from Zitadel to the header OAuth2 Proxy forwards and to the check the upstream app should make. Read each row as a contract between the identity provider, the proxy and the application, and confirm each claim in your own token before relying on it. The main takeaway is that the subject claim should key user records, while email and group values are for display and authorization checks.
| Identity signal | Source in Zitadel token | OAuth2 Proxy header or option | How the upstream app should use it |
|---|---|---|---|
| User ID | Subject claim (sub), stable per user | X-Forwarded-User (confirm which option exposes the subject in your version) | Use as the primary key for user records, audit trails and ownership. Do not key on email or username. |
| Email claim, included when the email scope is requested | X-Forwarded-Email | Display and notifications only. Treat as mutable and confirm it is verified before using it for account linking. | |
| Groups | Group or role claims as configured in Zitadel actions or token settings | X-Forwarded-Groups | Map group names to app roles in a fixed lookup table. Reject unknown groups rather than granting a default role. |
| Project roles | Role keys granted to the user in the Zitadel project | Confirm whether roles reach the header or must be read from the access token | Check roles server side on every request, not only at login, so revoked grants take effect. |
| Username | Preferred username claim, if included in the token | Confirm the header and option for your OAuth2 Proxy version | Use for display or logs only. Usernames can change, so they are not a stable identifier. |
| Token passed upstream | Access token or ID token issued by Zitadel | Pass-access-token or pass-authorization-header options (confirm names in the configuration overview) | Only forward a token if the app validates it. Otherwise rely on headers from the trusted proxy alone. |
How sessions and token refresh behave behind the proxy
Decide the session store before rollout, because it determines how OAuth2 Proxy keeps a user signed in and what happens when tokens refresh. The two options are encrypted client-side cookies and Redis. With cookie sessions, the session lives in an encrypted cookie in the browser, the proxy holds no session state of its own, and you must provide a cookie secret that is identical across every proxy replica. With Redis, the cookie carries only a ticket and the session data sits in the store, which can be a single instance, Redis Sentinel or Redis Cluster. The OAuth2 Proxy session storage documentation describes both modes, and your platform team should confirm which Redis topology they already operate and support before choosing Redis.
The trade-off that matters most is locking. OAuth2 Proxy cannot lock a cookie session, so if a user has several tabs or API calls that trigger token refresh at the same moment, two requests can refresh against Zitadel with the same refresh token and one will fail. The visible result is that the user is sent back to the Zitadel login page for no obvious reason. Redis sessions avoid this exposure to the same degree because the session record is shared and can be managed centrally. Test this with the applications you intend to protect, especially single-page front ends and background requests that run while a user is idle, and confirm with Zitadel which refresh token behavior your application configuration uses.
Treat the session store as a design decision with an owner, not a default. Record the chosen mode, the cookie secret or Redis topology, the session lifetime and the refresh behavior in your rollout plan, and rotate the cookie secret through a documented process. If your teams expect many concurrent requests per user or the protected apps are chatty, Redis is usually the safer starting point, while small internal tools with simple navigation may run acceptably on cookies. Ask your DeployOpen engagement lead to include a concurrent-refresh test in the acceptance criteria so the decision is verified rather than assumed.
Security settings for this integration
OAuth2 Proxy becomes the gatekeeper for every request to the internal app, so its secrets, redirect configuration and trust boundary decide how much the login actually protects. The cards below cover the settings that most often weaken this pattern. Confirm each value against the current OAuth2 Proxy and Zitadel documentation for the versions you deploy.
Keep secrets out of version control
The Zitadel client secret and the OAuth2 Proxy cookie secret should be injected at runtime from a secrets manager or Kubernetes secret, not written into a configuration file committed to Git. Anyone who reads the cookie secret can forge or decrypt session cookies, and anyone with the client secret can impersonate the application. Rotate both on a schedule and after any repository exposure. Confirm the exact configuration keys and encoding rules for the cookie secret in the OAuth2 Proxy configuration overview.
OAuth2 Proxy configPin the redirect URL to the proxy host
Register the redirect URL in the Zitadel web application as the exact proxy hostname and callback path, with no wildcards and no shared hostnames for other apps. A loose redirect list lets an attacker craft a login that returns the authorization code to a host they control. Use HTTPS only and keep the path identical in the OAuth2 Proxy redirect setting. Check the registration against the Zitadel OAuth2 Proxy example before go-live.
Zitadel OAuth2 Proxy exampleRequire HTTPS on both hops
Terminate TLS at the proxy for browsers and use TLS between the proxy and Zitadel, so authorization codes, tokens and session cookies never travel in clear text. Mark session cookies as secure so browsers do not send them over plain HTTP. Also confirm that the Zitadel issuer URL uses HTTPS, because a mismatched issuer breaks token validation. Confirm the cookie and TLS option names for your OAuth2 Proxy version before you configure them.
Block direct access to the upstream app
OAuth2 Proxy passes identity to the app as headers such as X-Forwarded-User and X-Forwarded-Email, and the app trusts them because it assumes the proxy is the only caller. If a client can reach the app port directly, it can send those headers itself and impersonate any user. Restrict the app to the proxy network with firewall rules, a private Kubernetes service or a bind address on localhost, and test by sending a request with forged headers.
Header configurationLimit access by role and group
Authentication alone lets any user in the Zitadel organization reach the app, so decide which project roles or groups may enter each app. In Zitadel, grant roles to users through the project, and in OAuth2 Proxy enforce the allowed groups or claims so only matching users are admitted. Review grants when people change teams, because stale roles keep access open. Confirm how the role claim is named and emitted in your Zitadel project settings.
Choose the token forwarded upstream
OAuth2 Proxy can pass the access token or the ID token to the upstream app, and the choice changes what the app can do with it. Forwarding the access token gives the app a bearer credential for any API it trusts, while the ID token only asserts identity for the app itself. Forward only what the app needs, and keep the token out of logs. Verify which token type your OAuth2 Proxy version forwards by default and what audience Zitadel sets on it.
Testing login, role checks and logout before go-live
Agree the test plan with the app owner before anyone touches the production route, because the owner knows which headers the application trusts and which roles matter. Start with the unauthenticated request: a browser with no session that opens the protected hostname should be redirected to the Zitadel login page, and after sign-in it should land back on the original URL. Check the redirect URL registered in the Zitadel web application matches the callback that OAuth2 Proxy actually uses, since a mismatch is the most common first failure. Confirm the redirect does not loop and that no request reaches the upstream app before authentication succeeds.
Next test the authenticated path and the role boundary. A signed-in test user should reach the app, and the app should receive the expected X-Forwarded-User, X-Forwarded-Groups and X-Forwarded-Email values, which you can capture with a simple echo service behind the proxy. Then sign in as a user who exists in the Zitadel organization but lacks the project role the app requires, and confirm access is denied at the proxy or the application, not just hidden in the interface. Run the expired-session case by shortening the session lifetime in a test environment, then check that the refresh happens without a visible loss of work. Ask the app owner which roles and claims are authoritative, because OAuth2 Proxy forwards identity but the decision to allow access must be explicit.
Finish with concurrent refresh and logout. Because cookie sessions cannot be locked, open several tabs, let the token expire, and trigger requests from all of them at once; record whether any tab forces a fresh login, and decide with the owner whether that is acceptable or whether Redis-backed sessions are needed. Then test logout from one tab and confirm that the session cookie is cleared and a request from another tab is redirected to login. Retain the results as go-live evidence, and retest after any change to session settings or the OAuth2 Proxy version.
Common failures when OAuth2 Proxy and Zitadel are connected
This table lists the failures teams most often hit when OAuth2 Proxy sits in front of an app and signs users in through Zitadel. Each row gives the symptom, the likely cause and the fix to check first. Read it during the build and again after the first failed login, because most of these issues surface only once real users and real hostnames are involved.
| Failure | Likely cause | Fix |
|---|---|---|
| Redirect URI mismatch error at login | The redirect URL registered on the Zitadel Web application does not match the callback path on the proxy hostname, including scheme, port or trailing slash | Register the exact https callback URL for the public proxy hostname in the Zitadel application, then match the proxy redirect URL setting to it |
| Token exchange fails after Zitadel login | The application uses a different client authentication method than BASIC, so the client secret is not accepted at the token endpoint | Set the application type to Web and the authentication method to BASIC, as the Zitadel example for OAuth2 Proxy recommends, and confirm the client ID and secret in the proxy config |
| Users are logged out on every restart or deploy | The cookie secret is missing, changed or rotated, so existing encrypted session cookies can no longer be decrypted | Store one cookie secret in your secrets manager, inject it into every proxy replica, and change it only as a planned step that expects users to sign in again |
| Users are forced to log in again at random | Cookie sessions cannot be locked, so parallel requests that refresh the same token can conflict | Move to Redis-backed sessions for multi-replica or busy apps, and confirm the refresh behavior in your test plan before go-live |
| Upstream app receives no user headers | Traffic reaches the app directly, bypassing the proxy, so X-Forwarded-User and related headers are never added | Restrict the app to accept traffic only from the proxy network path, and test a direct request to confirm it is refused |
| Role or group checks fail for valid users | The role claim or project grant was not configured in Zitadel, so the token carries no roles or groups for the proxy to forward | Grant the user the project role in the correct organization, enable the role claim for the application, and verify the groups header in a test session |
Questions buyers ask about protecting internal apps with OAuth2 Proxy and Zitadel
How long does it take to protect one internal app with OAuth2 Proxy and Zitadel?
Duration depends on the app's session needs, the role model and how many environments must be covered, so no single figure applies to every app. A single app with one hostname, one Zitadel web application and a simple role check is usually the shortest path, because the main steps are creating the Zitadel application with the authorization code flow and BASIC client authentication, registering the redirect URL, deploying OAuth2 Proxy in front of the app and testing login, logout and header forwarding. Add time for each extra environment, each role that must be enforced and any session storage choice beyond the default cookie setup. Ask any provider for a written, fixed-scope timeline that lists these items separately.
Can our platform team do this work in-house?
Yes, many platform teams can do it in-house, since the Zitadel documentation includes an OAuth2 Proxy example that recommends the Web application type with BASIC authentication. The harder parts are the decisions around them: how roles map to Zitadel projects and grants, how upstream apps trust the forwarded user, group and email headers, and how sessions behave under load. Teams that already run Zitadel and have reverse proxy experience usually move faster. Teams without that experience should plan time to learn the session and header behavior, and should test logout and token refresh before relying on the setup for users.
What does our team need to provide before the work starts?
The work needs a named owner for each internal app who can confirm who should have access and which roles apply. You also need a role model written down in plain terms, the hostnames each app will use, and TLS certificates for those hostnames. Your team should provide a running Zitadel instance or agree on its setup, access to the infrastructure where OAuth2 Proxy will run, and a decision on session storage, either encrypted cookies that need a cookie secret or Redis for shared state. Confirm the app's support for forwarded identity headers, because some apps need configuration changes before they can accept them.
What drives the cost of protecting internal apps with OAuth2 Proxy?
Cost is driven mainly by the number of apps, the complexity of the role model and the session design. Each additional app adds a Zitadel application or project setup, a proxy configuration, hostname and certificate work and testing. Role complexity adds effort because each role check must be defined, mapped to Zitadel grants and verified for every app that uses it. Session design matters because cookie sessions need a secret and carry a known limitation: sessions cannot be locked, so concurrent token refreshes can force users to log in again. Redis adds infrastructure to run and back up. The OAuth2 Proxy and Zitadel software is open source, so the recurring costs are your infrastructure and the people who operate it. Ask any provider for a quote that itemizes these drivers.
Do our internal apps need code changes to sit behind OAuth2 Proxy?
Usually not, because OAuth2 Proxy can act as the reverse proxy in front of an app and handle the login flow there. The app does need to read identity from request headers, such as X-Forwarded-User, X-Forwarded-Groups or X-Forwarded-Email, and that is where the check matters. The app must accept these headers only from the proxy. If clients can reach the app directly or can set the same headers themselves, anyone can impersonate a user. Confirm that the app is reachable only through the proxy, that the proxy strips or overwrites incoming identity headers, and that the app's authorization logic uses the headers as intended. Apps that need the access token themselves may need changes.
How does Zitadel Enterprise support or a retainer change the ongoing work?
Zitadel Enterprise adds custom support agreements and technical account management from Zitadel, which covers the identity platform itself. DeployOpen's ongoing support, upgrades and continuous testing are available as retainers, which cover the OAuth2 Proxy layer, the protected apps and changes to roles and hostnames. The two are separate: a Zitadel support agreement does not configure or test your proxy rules, and a retainer does not replace vendor support for Zitadel. Ask what each covers, who responds to incidents, how Zitadel upgrades are tested against the proxy configuration, and whether the retainer scope includes new apps. Confirm the terms of any Zitadel plan with Zitadel directly, since pricing and support terms are published on its pricing page.
What should we check on OAuth2 Proxy session handling before go-live?
Check how sessions are stored, how long they last and how the proxy behaves when tokens are refreshed. With the default encrypted client-side cookies, OAuth2 Proxy holds no state of its own, but sessions cannot be locked, so concurrent refreshes from several browser tabs or API calls can conflict and require a new login. Test this with realistic user behavior, including multiple tabs, long-running pages and logout from one tab while another remains open. If that behavior is unacceptable, evaluate Redis, which keeps only a ticket in the cookie. Confirm the cookie secret is generated and stored securely and that logout clears the session both in the proxy and at the identity provider.
How DeployOpen scopes and delivers this integration
DeployOpen plans, configures, tests and documents the OAuth2 Proxy and Zitadel integration inside your own infrastructure, and most engagements of this kind are fixed-scope: the scope, deliverables and timeline are agreed in writing before work starts. In practice that means the first step is an inventory of the internal applications to be protected, the Zitadel instance and organization they will sign in through, the hostnames each proxy will serve, and whether each app needs identity headers, group-based role checks or both. Those answers determine the number of proxy deployments, the Zitadel projects and roles to create, and the session storage choice. A written scope turns those decisions into named deliverables that your security and platform teams can review before anything is deployed.
The deliverables typically cover the Zitadel web application configured for the authorization code flow with BASIC client authentication, the redirect URL registered for each proxy, the OAuth2 Proxy configuration and secrets handling, the session storage design, the header mapping that uses the subject as the user ID, and the role check rules. DeployOpen also documents the runbook, including how to rotate client secrets and cookie secrets and what to do when sessions need to be reset. Where you ask for it, DeployOpen can test the protected applications for authorization gaps, such as paths the proxy does not cover, headers a client could forge, or roles that grant more than intended. Confirm during scoping whether that testing is part of the fixed scope or a separate engagement.
Ongoing work is covered by retainers. OAuth2 Proxy publishes regular releases, so a retainer can include upgrades, configuration reviews after Zitadel changes and continuous testing of the protected apps. When you request a quote, ask for the written scope to list each application, the environment it runs in, the Zitadel and OAuth2 Proxy versions in use at the time of work, who performs and approves each deliverable, and what is handed over at the end. Ask how the retainer is priced and what it excludes, so that upgrade and testing work is clear before it starts.

