Apache httpd OpenID Connect login with Zitadel

Put single sign-on in front of legacy web apps served by Apache, using mod_auth_openidc against a Zitadel PKCE application. This page covers the setup sequence, claim mapping, logout and the failure points to test before cutover.

On this page

How Apache httpd can sign users in through Zitadel without changing the app

Many teams run legacy applications behind Apache httpd that have no modern login support, and they need Zitadel sign-in without rewriting the apps. The supported path is mod_auth_openidc configured as an OpenID Connect relying party against a Zitadel application of type PKCE. Zitadel's Apache 2.0 guide sets up that application and points the module at the Zitadel discovery endpoint through OIDCProviderMetadataURL, along with OIDCClientID and OIDCRedirectURI. Apache then handles the redirect to Zitadel, the callback, and the session, so the backend application receives an already authenticated request.

The design decisions sit at the web server and the identity side. Decide which virtual hosts and paths require a session, which paths must stay open (health checks, static assets, callbacks), and how the session cookie is scoped and expired. On the Zitadel side, decide which project and organization hold the application, and which user attributes the backend needs. Confirm in the mod_auth_openidc documentation for your installed version which directives control the session, the logout behavior and the claims passed to the backend, since names and defaults can change between releases.

Passing claims is where legacy apps usually break. mod_auth_openidc can expose user claims to the backend as request headers, and the backend trusts those headers only because Apache sets them. Plan for header stripping on inbound requests so a client cannot forge identity headers, restrict the backend to accept traffic only from Apache, and check that each claim the app uses is actually present in the tokens Zitadel issues for your application. Test the full flow with a user who lacks an expected attribute, and confirm how the app behaves when the session expires mid-request.

What you need in place before configuring Apache

Before anyone edits a virtual host, the Zitadel instance, the Apache host and the public hostnames need to exist and be owned by named people. The cards below cover the components and decisions that the Apache configuration depends on, so that a failed login can be traced to one layer rather than to all of them at once.

Self-hosted Zitadel and PostgreSQL

Zitadel stores its data in PostgreSQL, and the supported database versions for self-hosted Zitadel are 14 through 18. Confirm that the database you plan to use falls in that range before the Zitadel instance is built, and confirm the Zitadel release you will run against Zitadel's current release notes. The Apache integration depends on a working Zitadel instance, so a broken database layer will look like an Apache login problem.

Supported PostgreSQL versions
14 to 18
Zitadel database docs

Apache host and module availability

The Apache host must run httpd with the mod_auth_openidc module installed and enabled. Packaging differs between Linux distributions, so confirm the module package name, the version it ships and whether your distribution supports the Apache release you run. Check the mod_auth_openidc version against your distribution and Zitadel's current release notes, because a module that is too old may not handle the discovery and PKCE behavior your setup expects.

Public HTTPS hostnames

You need two public HTTPS hostnames: one for the Zitadel instance that serves the discovery endpoint and login pages, and one for the Apache site that the user visits. Both must resolve in DNS and present valid certificates that the browser and the Apache host trust. Redirect URIs and the issuer are compared exactly, so the hostnames must match the values you register in Zitadel character for character, including scheme and port.

Zitadel project and application owner

Name one person or team who owns the Zitadel project, the application entry for the legacy app and the redirect URIs. That owner decides who may change the client settings, who receives the client ID and who approves a change to the logout URI. Without a named owner, a changed hostname on the Apache side often goes unfixed on the Zitadel side for weeks, and users see redirect errors that nobody is assigned to resolve.

Apache virtual host owner

Name the team that controls the Apache virtual host, the TLS certificates, the module configuration and the backend application behind it. This team must be able to restart Apache in a maintenance window and read the error log during testing. Agree in advance who signs off the change, because the configuration touches authentication for every path the virtual host protects.

Client secret and config storage

Decide where the client secret and the Apache configuration file live before you write them. Restrict read access to the Apache configuration, since it contains the client ID and may contain the secret, and record who can rotate it. Confirm with the Zitadel project owner how the client authentication method is set for this application, because the Apache configuration must match it exactly.

How to configure the Zitadel application and Apache module in sequence

This sequence takes you from an empty Zitadel project to a verified login round trip through Apache httpd, with a checkpoint after each change so faults are found where they were introduced. Work through it in order on a staging host before touching production.

  1. Create the Zitadel project and PKCE application

    In the Zitadel console, create a project for the legacy web app, then add an application of type PKCE inside it. The Zitadel Apache 2.0 guide sets up this application type for the mod_auth_openidc integration, so choose it rather than a generic web application. Confirm that the application appears in the project and that its client ID is displayed. The step is done when you can open the application settings without errors and the client ID is visible.

  2. Record the client ID and discovery URL

    Copy the client ID from the application details and store it in your secrets process, not in a shared document. Note the Zitadel instance domain you will use for the discovery endpoint, since the Apache module reads its provider metadata from that address. Check the value against the instance domain your Zitadel deployment actually serves, because a mismatch here is a common source of failed logins later. The step is done when the client ID and the full discovery URL are written down and reviewed by a second person.

  3. Set the redirect and logout URIs

    Register the redirect URI for the Apache host in the application settings, using the callback path that mod_auth_openidc will serve on that virtual host. Register the post-logout URI the same way if the legacy app needs a logout landing page. Match scheme, host and path exactly, since Zitadel will reject a callback that differs from a registered value. The step is done when the saved application lists the redirect URI you intend to use, with no trailing differences from the Apache configuration.

  4. Verify the Zitadel discovery document

    Before editing Apache, fetch the discovery document from the discovery endpoint using curl or a browser from the Apache host itself. The response is a JSON document that lists the issuer, authorization, token and userinfo endpoints. Confirm that the issuer value matches the instance domain you recorded, and that the host can reach the endpoint over TLS. The step is done when the request returns the metadata without certificate errors. If it fails here, fix the network path or trust store now, because the Apache module will fail the same way.

  5. Configure the mod_auth_openidc directives

    On the Apache host, load the mod_auth_openidc module and set OIDCProviderMetadataURL to the Zitadel discovery endpoint. Then set OIDCClientID to the client ID you recorded and OIDCRedirectURI to the same callback registered in Zitadel. Keep the client secret out of the main configuration file, and reference it through the mechanism your Apache packaging supports. Validate the syntax with the Apache configuration test command, then reload the service. The step is done when the configuration test passes and the reload completes without module load errors.

  6. Protect the legacy location and pass claims

    Add an authentication block to the location that serves the legacy app, requiring a valid OpenID Connect session for it. Decide which user claims the backend needs, such as the subject or email, and configure the module to pass them as request headers to the application. Confirm the claim names against what your Zitadel application actually returns, since the names are set by your token and scope configuration. The step is done when a request to the protected path is redirected to Zitadel rather than served directly.

  7. Test the login round trip and logout

    Open the protected path in a private browser session and sign in through Zitadel. Confirm the redirect returns to the registered callback, the legacy app loads, and the expected claim headers reach the backend, which you can check in a test page or application log. Then test logout and confirm the session ends and the post-logout URI is reached. Repeat the test with a second user to confirm claims are per user. The step is done when both login and logout complete on a clean session and the claims match the test users.

How the browser, Apache and Zitadel exchange the login

The login starts when a browser requests a protected path on the public Apache edge, which has no session and redirects the user to Zitadel's authorization endpoint with a PKCE challenge. After the user signs in, Zitadel sends the browser back to the OIDCRedirectURI on Apache, where mod_auth_openidc exchanges the code, validates the tokens and opens a session. Apache then proxies the request to the internal backend with user claims in headers. Check that the trust boundary sits where the backend accepts only traffic from Apache.

Login flow between browser, Apache, Zitadel and the internal backend.

Which Zitadel claims reach the backend and how the app reads them

This table maps the OIDC claims Zitadel issues to the headers or environment variables a backend receives through mod_auth_openidc, and shows where role and organization values come from. Read each row as a question to answer with your own test users, since claim names and passing options depend on the module version and its configuration. The main takeaway is that the backend should trust only what the module passes through after validation, and that roles depend on project grants being set up correctly in Zitadel.

Claim or valueWhat Zitadel suppliesWhat to confirm before the app relies on it
Subject (sub)A stable user identifier issued by Zitadel for each userWhich header or variable the module exposes for the subject, and that the app keys accounts on it rather than on email
EmailThe user's email address, included when the requested scopes and user data allow itThat the email claim is present for every test user, and whether the app should treat it as a unique or changeable identifier
NameThe display name from the Zitadel user profileThe exact claim name the module passes to the backend, and how names with special characters are encoded in headers
Roles from project grantsRole keys granted to the user within a Zitadel project, returned in a project roles claim when role assertion is enabledThat role assertion is enabled for the application, the claim name format, and how the app parses a multi-valued claim
Organization or tenant contextThe organization the user belongs to, exposed through organization-related claims in the tokenWhether the org claim reaches the backend, and whether the app checks it against the organization it serves
Authentication contextTiming and method claims that show when and how the user signed inWhether the backend needs them for session age checks, and which of these the module forwards
Header passing and trustClaims are read from the validated session, then forwarded to the application as headers or environment variablesWhich passing option your version uses, and that client-supplied headers with the same names are stripped at the proxy

How logout, session lifetime and redirect paths behave

When a user logs out of the Apache-protected application only, the module clears its own session on the Apache host. The next request to a protected path then sends the browser back to Zitadel. The Zitadel session itself stays active, so the user may be signed in again without entering credentials. This is the outcome when no logout request reaches Zitadel, and it protects one application rather than the browser session that other applications may share.

  • Cookie scope: The session cookie is set by the Apache host, so only protected paths on that host lose it.
  • Silent re-entry: If the Zitadel session is still active, the redirect back to login can complete without a password prompt.
  • Other applications: Other applications that use the same Zitadel instance keep their sessions, which can surprise users who expected a full sign-out.
  • Backend state: Server-side data kept by the application is cleared only if the application handles logout, so confirm that with the application owner.

Test this by signing out locally, opening a protected page in the same browser, and noting whether a login prompt appears.

Security settings that matter for an Apache OIDC front end

An Apache front end that authenticates users with Zitadel decides who reaches the backend, so the client method, transport, session handling and trust boundary all sit in one path. The cards below cover the settings to review before go-live, and each one needs confirmation against the module version you deploy.

PKCE as the client method

The Zitadel Apache guide sets up the application as type PKCE, so the module exchanges the authorization code without relying on a client secret that must be stored on the web server. Confirm that the application type and token endpoint authentication in Zitadel match what the installed mod_auth_openidc release expects, because a mismatch shows up as a failed code exchange rather than a clear error. Review the application's allowed redirect URIs so only the Apache callback path is listed.

Zitadel Apache guide

TLS on every redirect and metadata endpoint

The discovery URL, the authorization and token endpoints, the redirect URI and the logout target all carry sensitive values, so each should use HTTPS with a certificate the Apache host trusts. Check that the OIDCProviderMetadataURL resolves to the Zitadel instance over TLS and that the Apache host trusts the internal certificate authority if Zitadel runs in a private network. Apache should not accept plain HTTP redirect URIs in production.

Cookie and session encryption

The module stores the authenticated session in a cookie that the browser returns on each request, so its encryption and lifetime decide how long a stolen cookie stays useful. Confirm the module's options for the cookie crypto passphrase, the session inactivity timeout and the maximum session lifetime in your installed version, and set them to values your policy approves. Use the Secure and HttpOnly attributes that the module sets by default, and check them in the browser after deployment.

Path protection scope

Protection applies to the locations you declare, so a broad or missing Require valid-user directive can leave an admin or API path open. Map each Location or Directory block to an explicit rule, and list public paths such as health checks and static assets as exceptions with a reason. Test unauthenticated requests to every protected path and to paths with trailing slashes or encoded characters.

Forwarded claims trusted only from Apache

The module passes user claims to the backend as request headers, and a backend that reads those headers will trust whatever arrives. Strip any inbound headers that carry claim names before Apache sets them, and make the backend accept identity only from the Apache host, for example through a private network path or a shared secret the backend checks. Confirm the header names and the claim prefix in the module documentation for your version.

Signing keys and client secrets

Token signature validation and any client secret or crypto passphrase are the values most likely to be copied into configuration files and backups. Confirm with the module's current options whether your release needs a client secret, how it reads secrets from files or environment settings, and how key rotation is handled when Zitadel rotates signing keys. Restrict file permissions on the Apache configuration and record who can read these values.

Why the redirect loops or the discovery check fails

This table lists the failures teams hit most often when mod_auth_openidc is pointed at Zitadel, with the likely cause and the fix for each. Check the rows in order: most redirect loops trace back to a URI mismatch, and most discovery failures trace back to network reach or certificate trust.

SymptomLikely causeFix
Redirect URI mismatch error at loginThe OIDCRedirectURI in httpd does not exactly match a redirect URI registered on the Zitadel application, including scheme, host, port and path.Copy the redirect URI from the Apache configuration into the Zitadel application, then restart httpd and retry in a private browser window.
Login loops back to the same pageThe redirect URI path is handled by the backend app instead of mod_auth_openidc, or the session cookie is not stored, so the module starts a new login each time.Make sure the redirect path is served by the auth module location and that the session cookie is set and returned on the next request.
Discovery check fails or times outOIDCProviderMetadataURL points to a Zitadel endpoint that httpd cannot reach from its network, often because of DNS, egress rules or a proxy.Test the discovery URL from the Apache host with curl, then fix DNS, routing or proxy settings before changing the module configuration.
Certificate trust error on discovery or token callsThe Zitadel TLS certificate is issued by an internal or private CA that the Apache host does not trust.Add the internal CA to the system trust store used by httpd, or point the module at the CA bundle, and confirm the chain validates before retesting.
Token rejected because of clock skewThe Apache host and Zitadel clocks differ enough that issued-at or expiry checks fail.Confirm the Apache host syncs time with NTP, then check that the same time source is used across the environment.
Invalid client or unauthorized client errorThe OIDCClientID does not match the client ID of the PKCE application in Zitadel, or the application belongs to a different project or organization.Copy the client ID from the correct Zitadel application, confirm the application type is PKCE, and check which organization the application sits in.
Login succeeds but session cookie is lost behind a proxyThe cookie domain or secure flag does not match the public hostname seen by the browser, because TLS ends at a load balancer or reverse proxy.Set the cookie domain and secure settings to the public hostname, and confirm the proxy forwards the original host and protocol headers.
Backend receives no user claimsThe claims are not requested or not mapped into request headers, or the backend expects a claim name the token does not contain.Check the configured claim-to-header mapping, confirm the scopes include the claims you need, and log one decoded token from a test user to compare names.

Questions teams ask before configuring Apache with Zitadel

How much does it cost to put Apache behind Zitadel?

The cost has two parts: the Zitadel licence or plan, and the work to configure Apache and the backends. Self-hosted Zitadel core, Console and hosted login are licensed under the GNU Affero General Public License 3.0 from v3.0 onward, so the software itself has no per-user fee for self-hosting. Zitadel Cloud plans are priced separately, and the Zitadel pricing page lists a Free plan at US$0 per month with 100 daily active users, a Pro plan at US$100 per month including 25,000 daily active users, and custom Enterprise pricing. Engineering cost depends on the scope you agree in writing, so ask any partner for a quote tied to the number of virtual hosts and backends.

How long does an Apache and Zitadel login setup take?

Duration depends on how many virtual hosts, applications and backends need to sign in through Zitadel, and on whether the Zitadel application, redirect URIs and logout behavior already exist. A single host with a simple app can be configured in a short working session once the Zitadel PKCE application is created. Each additional virtual host adds its own client, redirect URI and test pass, and each backend that reads claims adds header mapping and authorization checks. Ask for a timeline in the written scope rather than relying on a general estimate.

Does our team need specialist skills to configure mod_auth_openidc?

A team with Apache administration experience and basic OpenID Connect knowledge can configure the module for a small number of hosts. The skills you need are editing Apache configuration, understanding the discovery URL, client ID and redirect URI, and reading token and claim behavior in logs. Zitadel administration skills are needed to create the project, PKCE application and roles. Teams with many legacy applications, custom session handling or unclear authorization rules usually benefit from an outside review of the design before rollout.

What makes the work bigger or smaller?

The main drivers are the number of virtual hosts, how many backends need user claims, and how much authorization logic sits inside each application. A single site that only requires a logged-in user is much simpler than a set of legacy apps that map groups or roles to permissions. Other drivers include how many Zitadel organizations and projects are involved, whether logout must reach every application, and whether the backends are tested with the same claim names. Each of these should appear as a line item in the written scope.

How do user claims reach the backend application?

mod_auth_openidc can pass validated user information to the backend in request headers, which the application then reads. The backend must trust only headers that Apache sets, so incoming client-supplied copies of those headers need to be removed at the proxy. Each backend that needs claims requires agreed header names, a mapping from Zitadel claims, and a test that confirms the values. Applications that expect a different identity format will need changes in their own code or a mapping layer.

What goes wrong most often with redirect and logout URIs?

The most common failure is a redirect URI in the Zitadel application that does not match the OIDCRedirectURI value in Apache character for character, including scheme, host, port and path. Logout problems appear when the front channel or back channel logout path is not registered or when sessions remain active in the browser after the Zitadel session ends. Test each virtual host with a fresh browser session, confirm the callback path works behind any reverse proxy, and check that logout returns the user to the expected page.

Should we use a partner or keep this work in-house?

Keep the work in-house when one or two hosts need simple login and your team already runs Apache and Zitadel. Consider a partner when the estate includes many legacy applications, when authorization depends on app logic, or when audit evidence for access controls is needed. DeployOpen plans, implements, hardens, documents and supports self-hosted open-source platforms in your own infrastructure, and most engagements are fixed-scope with the scope, deliverables and timelines agreed in writing before work starts.

How to test the login before moving users onto it

Test the login on a pilot virtual host before any user reaches the legacy application. Create a separate VirtualHost with its own server name, register a matching redirect URI on a test PKCE application in Zitadel, and point OIDCRedirectURI and OIDCClientID at that test client while production values stay untouched. Use a small, named test user set that covers the cases the application actually sees: a user from each organization that will sign in, a user with the roles the backend checks, and a user without those roles who should be refused. Run the flow in a clean browser profile, because an existing Zitadel session can hide a broken configuration. The setup steps are in the Zitadel Apache 2.0 guide.

Then test the edges of the session. Log out through the module's logout path and confirm that both the Apache session and the Zitadel session end, then check that the protected page sends the user back to sign-in. Test expiry by letting a session lapse, or by shortening the session lifetime on the pilot host, and confirm the user is returned to login instead of receiving cached content. For the negative test, send a request with a redirect URI that is not registered on the Zitadel application. Zitadel should refuse it, and you should see an error with no redirect to the address supplied. Confirm the exact logout and session behavior for your module version, since these settings can change between releases.

Record evidence the change reviewer can check without rerunning the tests. Keep the Apache configuration for the pilot host with secrets removed, a copy of the Zitadel application settings (authentication method, redirect and logout URIs, and grant type), and the test user list with the outcome of each case. Capture the timestamps and error responses from the negative test, plus the claim values the backend received for each test user, so the claims mapping can be reviewed. Record the module version and the Zitadel version under test, and name the person who approved each result. Ask your change board which format it accepts, since review requirements differ between organizations.

How DeployOpen scopes and delivers the Apache and Zitadel integration

DeployOpen plans, configures and hands over Apache httpd OpenID Connect login with Zitadel inside your own infrastructure. We start from the legacy applications, their hostnames and the claims their backends expect, then build, test and document the protected paths before anything goes live.

How we scope

  • Inventory each legacy app behind Apache, its hostnames, paths and the backend that reads user identity
  • Agree in writing which Zitadel instance, organization and project will host the PKCE application
  • Confirm the claims each backend needs, such as subject, email and roles, and how they map to Zitadel
  • Engagements are fixed-scope, with deliverables and timelines agreed in writing before work starts

How we build

  • Create the PKCE application in Zitadel and record the discovery URL, client ID and redirect URI per environment
  • Configure mod_auth_openidc in Apache with the discovery endpoint and the protected location blocks
  • Pass verified user claims to the backend through headers, and strip any client-supplied copies of those headers
  • Test sign-in, sign-out, session expiry and denied access on staging before production cutover

How we hand over

  • Deliver the Apache configuration, Zitadel application settings and a per-environment variable record
  • Document redirect and logout URI rules, certificate handling and how to rotate the client configuration
  • Walk through the claim-to-header mapping with the application owners and their security reviewers
  • Provide a retest of the protected paths after any agreed fixes so the handover reflects the running setup

How we support

  • Ongoing support, upgrades and continuous testing are available as retainers after handover
  • Re-validate the integration when Apache, mod_auth_openidc or Zitadel versions change
  • Ask your team to confirm log access, change windows and who approves Zitadel configuration changes before scoping
  • A quote follows from the written scope, so the support terms reflect the systems you actually run

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.