A single-container NGINX + oauth2-proxy reverse proxy gateway for securing upstream apps with GitHub OAuth2 login, cookie-based sessions, API key access, and email/domain restrictions.
docker pull leoustc/nginx:oauth2
docker-compose.ymlversion: "3.9"
services:
auth-gateway:
build: .
image: leoustc/nginx:oauth2
ports:
- "3000:80"
env_file:
- .env
.env# Public address used for OAuth redirect
PUBLIC_URL=https://sub.yourdomain.com
# OAuth2 provider credentials
OAUTH2_PROVIDER=github
OAUTH2_CLIENT_ID=Iv1.6a7b9a1e29xxxxxxxx
OAUTH2_CLIENT_SECRET=7c91394b587e3bbxxxxxxxx
# Secure random 32-byte cookie secret
COOKIE_SECRET=Z1dXu72lqRTy8KN5AOHCB9Qv5xxxxxx
# Whitelisted login identities
[email protected],[email protected],[email protected]
ALLOWED_DOMAINS=example.com,leoustc.com
# Where to send authenticated traffic
UPSTREAM_URL=http://127.0.0.1:3001
# Optional: extra directives to include in nginx.conf
NGINX_CONFIG_EXTRAS=
/ โ Requires GitHub login โ Reverse proxy to UPSTREAM_URL/oauth2/* โ Internal routes for auth/callback/session check/logout โ Clears session cookie and redirects to //github โ Admin redirect to GitHub App installation (if GITHUB_APP_SLUG is defined)Authorization: Bearer <API_KEY>https://code.leoustc.com/oauth2/callback
.envCOOKIE_SECRET must be exactly 16, 24, or 32 ASCII charactersPUBLIC_URL must match your deployed domain for OAuth to succeedALLOWED_EMAILS (comma-separated)ALLOWED_DOMAINS (comma-separated)NGINX_CONFIG_EXTRASdocker compose up --build
Then visit:
MIT โ Free for commercial or private use.
Content type
Image
Digest
sha256:956c260d3โฆ
Size
107.2 MB
Last updated
over 1 year ago
docker pull leoustc/nginx:oauth2