The Simplest Way to Make Nginx and Onelogin Work Like They Should

Published
Length
3 min read

Luis Felipe Dias

All posts

You pair nginx and onelogin to add single sign-on to internal web apps. OneLogin checks who the user is, and Nginx routes their traffic to the backend. Many legacy apps do not support modern login standards on their own. By putting Nginx in front, your team can enforce login rules before any request hits the app server. This setup keeps unauthorized users out of your internal tools and dashboards. How nginx and onelogin handle user login flows When a user visits an internal web app, Nginx ca

Your coding agents run with your access.

Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.

You pair nginx and onelogin to add single sign-on to internal web apps. OneLogin checks who the user is, and Nginx routes their traffic to the backend.

Many legacy apps do not support modern login standards on their own. By putting Nginx in front, your team can enforce login rules before any request hits the app server. This setup keeps unauthorized users out of your internal tools and dashboards.

How nginx and onelogin handle user login flows

When a user visits an internal web app, Nginx catches the request first. Nginx checks if the user has a valid session cookie for that domain. If no valid cookie exists, Nginx pauses the request and asks an auth helper service for help.

This helper service starts an OpenID Connect flow and sends the user to OneLogin. The user enters their password and completes a multi-factor check inside OneLogin. OneLogin then checks if the user belongs to the right group for that specific app.

Once the user passes the check, OneLogin sends a signed token back to the helper service. The helper reads the token, sets a session cookie, and tells Nginx the user is valid. Nginx then reads the user identity from the response headers and passes the traffic to the backend app.

This pattern keeps login logic out of your backend code. Your developers can build simple web services while the edge layer handles user checks. OneLogin stays the single source of truth for user roles and group memberships across the company.

Common failure modes and how to scope roles

A common mistake is sharing one OneLogin app profile across many different Nginx virtual hosts. When you do this, any user who logs into one tool can reach all the others. You should create a separate OneLogin app entry for each sensitive backend service instead.

Another frequent issue is passing broad tokens or raw session data straight to the backend app. If an attacker compromises one backend server, they might steal that token and use it elsewhere. Strip sensitive auth tokens at the Nginx layer and pass only the user email header downstream.

OneLogin + End-to-End Encryption: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Teams also forget to log which user ran which request once traffic passes the edge. By default, Nginx logs only the IP address and the path of the web request. You must update your Nginx log format to record the user email header from OneLogin on every line.

Long session lifetimes create another big risk for internal tools. If you remove a user from OneLogin, their active Nginx cookie might still work for hours. Set short cookie lifetimes and force the auth helper to re-check user status with OneLogin often.

How to lock down network paths between both tools

Your backend app servers should never accept direct traffic from the open corporate network. If a user can bypass Nginx and hit the app port directly, the OneLogin check means nothing. Use firewall rules so the backend server only accepts traffic from the Nginx host IP.

You also need to protect the headers that carry user identity from Nginx to the app. If Nginx does not clear incoming identity headers first, a user can send a fake email header. Always configure Nginx to overwrite any client-supplied user headers before sending the request upstream.

Finally, keep the client secret that connects your auth helper to OneLogin safe. Do not store this secret in plain text inside your version control system. Load the secret from a secure secret store when the server boots up, and rotate it on a set schedule.

Check database and API queries on the wire

Identity tools, roles, and network rules decide who opens a session. Setup alone cannot check what each query does or mask sensitive values in a response once a session starts. When workflows touch Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, or internal HTTP APIs, hoop.dev runs beside those services as an open-source proxy, a sidecar for your Postgres or API. It inspects requests coming in and results going back on the wire.

Your login details and client tools stay as they are while hoop.dev guardrails refuse bad deletes or drops before they run. On responses, hoop.dev data masking rewrites matched sensitive values in memory. Furthermore, hoop.dev holds SOC 2 Type II, is MIT licensed, and writes every query and decision to an audit trail that generates evidence for HIPAA, GDPR, and PCI DSS. See the source on GitHub.

Frequently asked questions

Can open-source Nginx talk to OneLogin on its own?

Open-source Nginx needs a small helper module or subrequest service to speak OpenID Connect with OneLogin. Paid Nginx Plus includes built-in modules that handle the OpenID Connect flow directly without extra services.

How do I pass OneLogin group roles to my backend app?

Set up OneLogin to include user groups in the token claims during the login step. Your Nginx auth helper reads those claims and passes them to the backend app as standard HTTP headers.

What happens when a user logs out of OneLogin?

Logging out of OneLogin does not clear the local Nginx session cookie right away. You should build a logout path on Nginx that deletes the local cookie and redirects to the OneLogin logout URL.

The query runs. The emails stay hidden.