All posts

How to Run OpenID Connect Behind an External Load Balancer Without Breaking Authentication

A failed login at 2 a.m. lit up every alert you own. The app was fine. The load balancer was not. If you run OpenID Connect (OIDC) behind an external load balancer, you already know the stakes. Misconfigure it, and tokens fail to validate. Configure it right, and users glide through authentication without noticing the infrastructure that makes it possible. The trouble is, OIDC is not just another HTTP service. It’s stateful where load balancers prefer stateless. It leans on redirects that don’t

Free White Paper

Service-to-Service Authentication + OpenID Connect (OIDC): The Complete Guide

Architecture patterns, implementation strategies, and security best practices. Delivered to your inbox.

Free. No spam. Unsubscribe anytime.

A failed login at 2 a.m. lit up every alert you own. The app was fine. The load balancer was not.

If you run OpenID Connect (OIDC) behind an external load balancer, you already know the stakes. Misconfigure it, and tokens fail to validate. Configure it right, and users glide through authentication without noticing the infrastructure that makes it possible. The trouble is, OIDC is not just another HTTP service. It’s stateful where load balancers prefer stateless. It leans on redirects that don’t play nice with lazy routing. And it depends on strict security rules that break when network layers get clever.

An external load balancer must handle four things for OIDC to work without pain:

  1. Sticky sessions. OIDC uses the state parameter to track auth flows. Without session affinity, users bounce between nodes mid-flow, losing that state and triggering failures.
  2. HTTPS termination. TLS must be terminated in a way that preserves headers like X-Forwarded-Proto and exact redirect URIs. Even one mismatch breaks the handshake with your Identity Provider (IdP).
  3. WebSocket or long-polling readiness. Many modern OIDC-based apps use silent token refresh or backchannel connections. Your load balancer has to pass them as-is.
  4. Correct idle timeout settings. Long-lived OIDC sessions die abruptly if the load balancer closes connections too soon.

The most common cause of OIDC issues with an external load balancer is subtle mismatch between what your IdP expects and what your load balancer does by default. This includes incorrect forwarding of host headers, failing to preserve query strings, and redirect rewrites that silently break OAuth2 flows.

Continue reading? Get the full guide.

Service-to-Service Authentication + OpenID Connect (OIDC): Architecture Patterns & Best Practices

Free. No spam. Unsubscribe anytime.

When you set up OIDC in production, you cannot depend on defaults. Map every route involved in the /authorize and /callback sequence. Confirm SSL termination matches what your IdP’s metadata specifies. Test token refresh under peak load. Then test again after failover.

The choice of load balancer—NGINX, HAProxy, AWS ALB, GCP External HTTP(S) Load Balancer—affects how you handle these details. Some support native OIDC proxying, others demand explicit rules. What matters most is not the brand but that every header, cookie, and redirect survives the round trip intact.

A clean OIDC integration makes authentication invisible. A poor one makes it the bottleneck. The gap is in configuration and validation, not in the protocol itself.

You can skip weeks of setup and validation. Hoop.dev runs secure OIDC authentication behind a fully managed external load balancer out of the box. No guessing at headers. No broken flows. You see it live in minutes, with production-grade settings already in place.

Ready to stop debugging OIDC at 2 a.m.? See it working on your stack today at Hoop.dev.

Get started

See hoop.dev in action

One gateway for every database, container, and AI agent. Deploy in minutes.

Get a demoMore posts