I remember wanting to put several existing web apps behind one login. Each system worked, and I didn’t want to change every codebase just for this. Users might have bookmarked a particular page or opened a link sent by a colleague. Even the prettiest unified login homepage would be irrelevant to someone following an old bookmark straight to the app.
Around noon on April 11, 2025, I looked up OpenResty, Kong, and Traefik and started reading about Lua. Looking back, a gateway appealed for a concrete reason: could it catch requests at the original URL, intervene when login was necessary, and leave all other pages and APIs to the original application? Answering that requires knowing who receives the first request and how the old app recognizes the person.
When someone opens an old bookmark, how does the gateway get the first request?
Take https://assets.example.com/devices/42. There are two ways to keep that address. If the application already supports unified login, it can receive the request itself, initiate login, and return the user to device 42. If a gateway must check requests centrally, you need authority to change DNS or the existing load balancer so traffic for assets.example.com reaches the gateway first. Configure a certificate covering that domain at the HTTPS entry point. Merely adding portal.example.com leaves traffic from the old bookmark going straight to the app.12
Once wired in, one gateway can distinguish the asset system from the ticketing system by hostname. When someone opens device 42 without a valid session, the gateway remembers the site-local path and sends the browser to unified login. After authentication the browser returns to the original page. Even when the gateway allows passage, the asset system must recognize the current account before it can decide whether that person may see device 42.
What login mechanism does the legacy app already support?
Single sign-on (SSO) lets someone who has proved their identity in one system continue using their account when opening another. Each system can keep its own sessions and permissions. Apps that integrate with the same identity provider can also use passkeys or multifactor authentication there without ever handling the unified login password. Before selecting a product, I’d inspect each app’s authentication settings.3
| Existing app capability | Integration option | What happens next time someone opens the old bookmark? |
|---|---|---|
| Configurable OpenID Connect (OIDC) or SAML | Have each app trust the same identity provider, the service that centrally verifies users. The app validates the login result and associates it with a local account.43 | When an app session expires, the identity provider’s existing login may establish a new one. A gateway is usually unnecessary for SSO alone. |
| Trusts identity from a reverse proxy | The gateway authenticates, and the backend reads an agreed identity header. For example, Grafana can read a username from X-WEBAUTH-USER. The gateway must strip externally supplied copies of that header and write the verified value. The backend must restrict trusted sources.5 | Opening the bookmark identifies the account. Its app permissions still determine which data it may see. |
| Accepts only its own form and sessions, and occasional repeat login is acceptable | Check access eligibility at the gateway and let users sign in to the old app themselves with its own session cookie.6 | A valid old session works directly. After expiry the login page returns, preserving a step in which users verify themselves. |
| Accepts only its own passwords, and the business requires automatic sign-in after session expiry | With user authorization, bind each person’s old account. A credential service holds a separate password per account. First confirm that the app’s login, password change, and extra verification flows allow this integration.7 | An expired session can be re-established on the user’s behalf. Users still participate whenever the app requires additional verification. |
The third and fourth rows are easy to confuse in a demo. Open a bookmark in a browser that was logged in yesterday and both may go straight to the device page. Try a new browser or explicitly end the old app session first. Following the same link then reveals who actually completes the next login.
After the gateway lets a request through, who opens the original page?
Opening the device page sends GET /devices/42. Provided the asset system already recognizes the user, the gateway can forward the request and return the resulting page. Images, APIs, and downloads can use the same route. The gateway needn’t understand every business endpoint. “Forward unchanged” here means the path, parameters, and business content can be preserved. A proxy may still adjust Host, cookies, or other headers to suit the deployment.8
That was why I was looking at gateways. I wanted one login check. The asset system should still retrieve device information and decide who may see it. The check can live in OpenResty, or the gateway can call a separate authentication service. Either way, the downstream app must accept the identity or have a valid session it issued itself. See Should gateway authentication live in OpenResty Lua or a separate service?.
If the old app only accepts cookies, where does the login state live?
Suppose the gateway has used a login flow permitted by the old app to obtain a session cookie for the user. It can keep that cookie in either of two places. The same bookmark works in both cases.
In the browser. The browser is visiting assets.example.com, so the gateway can forward the old app’s Set-Cookie in a response from that hostname. Without a Domain attribute, the browser stores the cookie under the current host and sends it on a subsequent request to a matching path. If the old app hardcodes an internal domain or path, adapt it at the proxy. A cookie returned only by portal.example.com and scoped to sibling domain assets.example.com will be rejected.69
On the server. The browser holds only a gateway-issued session identifier. For each pair of gateway session and target app, the gateway retrieves the corresponding legacy session and forwards only that app’s required cookies. Apps needn’t see one another’s cookies, but the session store now provides access to apps on users’ behalf. Isolate entries by user and apply expiration. On logout, clear the mapping and invalidate the old session if the app supports it. Whichever side stores a cookie, it represents only an established session. You still need a login mechanism after expiry.
Is it worth having the gateway generate random passwords?
I considered the following approach. On first binding an asset account, a user verifies their old password through the asset system and consents to delegated management. The account management service uses the existing password-change function to give that person’s asset account a random password. Binding a ticketing account generates another independent password. The original is used only during binding and never stored or logged. If the legacy session later expires, the delegated login service can retrieve the new password from a dedicated vault. This assumes the password belongs only to that app. If several apps share a directory account, changing it affects the others too.310
That avoids keeping a password the user may reuse elsewhere. The original password becomes invalid immediately, and the delegated service now holds a working credential. Regular rotation can shorten the useful lifetime of a leaked password. If a valid session cookie leaked instead, the answer depends on whether the app can revoke that session. If read access to the vault leaked, revoke the access first. For unified login passwords memorized by users, NIST gives separate guidance: “Verifiers and CSPs SHALL NOT require subscribers to change passwords periodically.” The same provision requires a change when there’s evidence of compromise.1011
Automatic rotation also has an easily overlooked failure mode: the old app accepts the new password, but the rotation process exits before updating the vault. To take this route, securely store a pending version in the vault first, then request the change, verify the new password, and finally mark the version current. After an interruption you should be able to reconcile the two versions and recover. For a project intended simply to save a few logins, that’s real maintenance overhead. For how to run rotation independently and let the gateway handle only sessions, see Service responsibilities and forwarding with managed passwords.10
Returning to my original question, I’d start with an actual old bookmark and a browser that has no legacy session. If the app can use a unified identity provider, start there. If entry checks truly need centralization, choose an existing gateway and limit custom logic to authentication. When an app accepts only passwords, I’d first ask users: When the session expires, would you mind logging in once more yourself? If they’re willing, there’s one fewer set of passwords to manage. Pay for custody, rotation, and recovery only if the business really requires full automation. I no longer remember how far those particular apps ultimately got.
References
Footnotes
-
NGINX. (n.d.). How nginx processes a request(开篇“Name-based virtual servers”). nginx.org. https://nginx.org/en/docs/http/request_processing.html ↩
-
NGINX. (n.d.). Configuring HTTPS servers(Name-based HTTPS servers). nginx.org. https://nginx.org/en/docs/http/configuring_https_servers.html#name_based_https_servers ↩
-
OWASP Foundation. (n.d.). Authentication cheat sheet(Change Password Feature;Use of authentication protocols that require no password). OWASP Cheat Sheet Series. 改密时的身份验证;OIDC 与 SAML。 ↩ ↩2 ↩3
-
Sakimura, N., Bradley, J., Jones, M., de Medeiros, B., & Mortimore, C. (2023, December 15). OpenID Connect Core 1.0 incorporating errata set 2 (§1.3). OpenID Foundation. https://openid.net/specs/openid-connect-core-1_0.html#Overview ↩
-
Grafana Labs. (n.d.). Configure auth proxy authentication(
[auth.proxy]configuration). Grafana documentation. https://grafana.com/docs/grafana/latest/setup-grafana/configure-access/configure-authentication/auth-proxy/ ↩ -
Microsoft. (2026, March 25). Password vaulting for single sign-on with application proxy(Overview;Test your app). Microsoft Learn. https://learn.microsoft.com/en-us/entra/identity/app-proxy/application-proxy-configure-single-sign-on-password-vaulting#overview ↩
-
F5. (n.d.). NGINX reverse proxy(Passing a request to a proxied server;Passing request headers). NGINX Documentation. https://docs.nginx.com/nginx/admin-guide/web-server/reverse-proxy/#passing-request-headers ↩
-
OWASP Foundation. (n.d.). Secrets management cheat sheet(Automate secrets management;Secret lifecycle). OWASP Cheat Sheet Series. 自动轮换与恢复;凭据生命周期。 ↩ ↩2 ↩3
-
National Institute of Standards and Technology. (2025, July). Digital identity guidelines: Authentication and authenticator management (SP 800-63B-4, §3.1.1.2, requirement 6). NIST. https://pages.nist.gov/800-63-4/sp800-63b.html#passwordver ↩