oauth2-proxy-patterns

Implement OAuth2 Proxy dual-instance deployment with Keycloak OIDC and nginx auth_request.

Updated Mar 2, 2026
One-click install
npx skills add https://github.com/MassimilianoPili/claude-code-config --skill oauth2-proxy-patterns
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: oauth2-proxy-patterns
Source: https://github.com/MassimilianoPili/claude-code-config/tree/main/skills/oauth2-proxy-patterns
Command: npx skills add https://github.com/MassimilianoPili/claude-code-config --skill oauth2-proxy-patterns

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill provides a robust framework for securing internal and external services using OAuth2 Proxy and Keycloak, ensuring secure authentication and authorization for applications lacking native OIDC support.

Core Features & Use Cases

  • Dual-Instance Deployment: Manages separate HTTP (internal) and HTTPS (public) OAuth2 Proxy instances.
  • Nginx Integration: Configures auth_request for seamless authentication delegation.
  • Visitor Access Control: Implements blocking for specific user roles at the Nginx layer.
  • Use Case: Protect a new internal dashboard with Keycloak authentication via OAuth2 Proxy and Nginx, ensuring only authenticated users can access it.

Quick Start

Configure a new service to be protected by the public OAuth2 Proxy instance using the provided nginx and docker-compose patterns.

Frequently Asked Questions about oauth2-proxy-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I secure internal services lacking native OIDC support with Keycloak and Nginx?

You secure internal services lacking native OIDC support by deploying OAuth2 Proxy as an authentication gateway alongside Keycloak. This pattern uses Nginx's auth_request directive to delegate authentication, ensuring only authorized users access your protected applications.

What is the best way to configure OAuth2 Proxy for both internal HTTP and public HTTPS traffic?

Configuring OAuth2 Proxy for dual-instance deployment is the best way to handle both internal HTTP and public HTTPS traffic. This setup separates internal network access from public exposure while maintaining consistent Keycloak authentication across both instances.

How do I block specific user roles from accessing services at the Nginx layer when using OAuth2 Proxy?

To block specific user roles at the Nginx layer, you implement visitor access control rules within your Nginx configuration. This intercepts requests authenticated by OAuth2 Proxy and restricts access based on role attributes passed from Keycloak.

Does OAuth2 Proxy support PKCE S256 when integrating with Keycloak as an OIDC provider?

Yes, OAuth2 Proxy supports PKCE S256 when integrating with Keycloak as an OIDC provider. This Proof Key for Code Exchange enhancement prevents authorization code interception attacks during the authentication flow.

Can I use Nginx auth_request to delegate authentication to OAuth2 Proxy for self-hosted applications?

Yes, you can use Nginx auth_request to delegate authentication to OAuth2 Proxy for self-hosted applications. This subrequest mechanism allows Nginx to verify user identity via OAuth2 Proxy before forwarding traffic to your backend service.

Why do I need separate OAuth2 Proxy instances for internal and external network access?

You need separate OAuth2 Proxy instances for internal and external access to isolate network security boundaries. This dual-instance deployment ensures internal HTTP traffic and public HTTPS traffic have distinct cookie management and authentication contexts.