惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

A
Arctic Wolf
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Google Online Security Blog
Google Online Security Blog
Help Net Security
Help Net Security
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
T
The Exploit Database - CXSecurity.com
Application and Cybersecurity Blog
Application and Cybersecurity Blog
S
Security Affairs
N
News and Events Feed by Topic
Forbes - Security
Forbes - Security
月光博客
月光博客
博客园 - Franky
The GitHub Blog
The GitHub Blog
O
OpenAI News
The Cloudflare Blog
Google DeepMind News
Google DeepMind News
P
Privacy & Cybersecurity Law Blog
WordPress大学
WordPress大学
H
Help Net Security
Apple Machine Learning Research
Apple Machine Learning Research
V
Visual Studio Blog
爱范儿
爱范儿
S
Secure Thoughts
T
The Blog of Author Tim Ferriss
SecWiki News
SecWiki News
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
J
Java Code Geeks
阮一峰的网络日志
阮一峰的网络日志
宝玉的分享
宝玉的分享
博客园_首页
Cisco Talos Blog
Cisco Talos Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
C
Cisco Blogs
博客园 - 三生石上(FineUI控件)
Hacker News: Ask HN
Hacker News: Ask HN
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
人人都是产品经理
人人都是产品经理
腾讯CDC
Know Your Adversary
Know Your Adversary
P
Proofpoint News Feed
云风的 BLOG
云风的 BLOG
The Last Watchdog
The Last Watchdog
博客园 - 叶小钗
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Hugging Face - Blog
Hugging Face - Blog
PCI Perspectives
PCI Perspectives
罗磊的独立博客
有赞技术团队
有赞技术团队
B
Blog RSS Feed
L
LINUX DO - 最新话题

NGINX Community Blog

External Authentication Policy in NGINX Ingress Controller: Patterns for VirtualServer and Ingress – NGINX Community Blog mTLS Policies in NGINX Ingress Controller – NGINX Community Blog Optimising NGINX Ingress Controller Startup Performance – NGINX Community Blog Meet With Us: NGINX Gateway Fabric & NGINX Ingress Controller Community Calls  – NGINX Community Blog Security, Performance, and Easier Migration – NGINX Community Blog Strengthening the NGINX Community – NGINX Community Blog F5 WAF for NGINX Comes to the Gateway API – NGINX Community Blog How NGINX Ingress Controller and NGINX Gateway Fabric Handle Kubernetes Backend Changes Natively – NGINX Community Blog Cache Policy in NGINX Ingress Controller: A Practical Guide for VirtualServer – NGINX Community Blog Access Control Policy in NGINX Ingress Controller: Patterns for Ingress – NGINX Community Blog Enterprise-Grade Features and Gateway API 1.5 Conformance – NGINX Community Blog NGINX OSS 1.29.6 and 1.29.7: Open-sourced Session Persistence, Multipath TCP and More – NGINX Community Blog Keep-alive to upstreams is now default in NGINX 1.29.7 – NGINX Community Blog CORS Policy in NGINX Ingress Controller v5.4.0: Patterns for VirtualServer and Ingress – NGINX Community Blog A Community Hub for NGINX on Kubernetes, Including a New Ingress-NGINX Migration Tool – NGINX Community Blog
External Authentication Policy in NGINX Ingress Controller: A Real World Use Case – NGINX Community Blog
Alex Fenlon, Paul Abel · 2026-06-22 · via NGINX Community Blog

NGINX Ingress Controller 5.5.0 introduced ExternalAuth, a new Policy type that lets you define external authentication once in a Policy resource and apply it consistently across both VirtualServer and Ingress traffic paths. This is the second blog post in a two part series that covers the ExternalAuth Policy, and is focused on a real world use case. You can find the first blog post in this series here.

Centralizing Auth Without Touching Application Code

A platform engineer is running a dozen microservices on Kubernetes behind NGINX Ingress Controller. The company already has an OAuth2 provider for employee SSO — GitHub in this example. Today, each team handles auth differently: one service uses a Go middleware library, another team rolled their own JWT validation, and a couple of internal services have no auth at all behind an “it’s on the private network” assumption. A security review flags the inconsistency, and the platform engineer is asked to enforce authentication across the board, but the dev teams are mid-sprint and won’t add auth middleware to their services right now.

The platform engineer needs to:

  • Protect the employee dashboard (/app) with OAuth2 so employees sign in with their existing identity provider — no new passwords, no code changes in the dashboard service.
  • Protect the webhook receiver (/hooks) with HTTP Basic Auth for service-to-service calls from the CI pipeline — lightweight, no browser flow, just a shared credential validated against an htpasswd file.
  • Do this entirely at the ingress layer, without modifying or redeploying any application containers.

ExternalAuth policy solves this in two Policy resources and one VirtualServer update.

Step 1: Define the OAuth2 policy

Deploy oauth2-proxy configured with the company’s GitHub OAuth App, then create a Policy that points to it:

apiVersion: k8s.nginx.org/v1
kind: Policy
metadata:
  name: github-oauth2
  namespace: platform
spec:
  externalAuth:
    authURI: "/oauth2/auth"
    authSigninURI: "/oauth2/signin"
    authServiceName: "oauth2-proxy-svc"
    sslEnabled: true
    sslVerify: true
    sslVerifyDepth: 2
    sniName: "external-auth-tls"
    trustedCertSecret: "external-auth-ca-secret"

Any route referencing this policy will redirect unauthenticated browser requests into the OAuth2 sign-in flow. Authenticated requests pass through to the backend with the identity headers set by oauth2-proxy.

Step 2: Define the Basic Auth policy

For the CI webhook path, the platform engineer deploys a small basic-auth service backed by an htpasswd secret and creates a second Policy:

apiVersion: k8s.nginx.org/v1
kind: Policy
metadata:
  name: ci-basic-auth
  namespace: platform
spec:
  externalAuth:
    authURI: "/auth"
    authServiceName: "basic-auth-svc"
    sslEnabled: true
    sslVerify: true
    sslVerifyDepth: 2
    sniName: "external-auth-tls"
    trustedCertSecret: "external-auth-ca-secret"

Step 3: Attach the policies to routes

Both services share the same host, so they live in a single VirtualServer. Attach each policy at the route level so each path gets exactly the auth method it needs:

apiVersion: k8s.nginx.org/v1
kind: VirtualServer
metadata:
  name: platform
  namespace: platform
spec:
  host: platform.yourcompany.com
  tls:
    secret: platform-tls-secret
    redirect:
      enable: true
  upstreams:
  - name: dashboard
    service: dashboard-svc
    port: 8080
  - name: webhooks
    service: webhook-receiver-svc
    port: 8080
  routes:
  - path: /app
    action:
      pass: dashboard
    policies:
      - name: github-oauth2
  - path: /hooks
    action:
      pass: webhooks
    policies:
      - name: ci-basic-auth

What This Achieves

Employees browsing to platform.yourcompany.com/app are redirected to the OAuth2 sign-in page if they don’t have a valid session. CI jobs hitting platform.yourcompany.com/hooks authenticate with a service credential validated against the htpasswd file. Neither path ever reaches an application container without passing through the auth service first, and none of this required a single line of code in the dashboard or webhook services.

When a new microservice joins the platform later, the platform engineer just adds a route and references the appropriate policy. No new auth libraries, no dev team coordination, no per-service configuration drift.

Production Readiness Checks

Before rollout, validate these explicitly:

  • Unauthenticated requests receive a 401 and never reach backend pods.
  • If authSigninURI is set, unauthenticated browser requests are redirected rather than rejected.
  • The OAuth2 callback path (e.g. /oauth2/callback) is reachable on the same host.
  • trustedCertSecret contains the correct CA and sniName matches the auth service certificate’s SAN.

Security Considerations

External auth operates at the Ingress edge, so keep it tight:

  • Use sslVerify: true and a trustedCertSecret in production; skipping verification exposes the auth subrequest to interception within the cluster network.
  • Use authSnippets sparingly. Its contents are inserted verbatim into the auth location block and must be treated with the same care as any other NGINX configuration change.
  • The auth service is in your critical path; if it becomes unavailable, NGINX returns 500 to clients.
  • Review ExternalAuth policy changes with the same care as other auth-related configuration changes.
  • Because NGINX location blocks are defined at the server level, only one sign-in redirect location can exist per host. If multiple routes on the same host reference ExternalAuth policies with authSigninURI, NIC uses the sign-in redirect configuration from the first policy it processes. All routes on the same host that require OAuth2 sign-in must use the same OAuth2 Proxy backend. If you need different OAuth2 providers for different routes, use separate hosts.

You can find complete working examples on GitHub and more documentation in our docs:

NGINX Community Forum