Deploy OAuth2 Proxy
OAuth2 Proxy 7.15: Google, GitHub or OIDC login in front of any service
oauth2-proxy
Just deployed
Deploy and Host OAuth2 Proxy on Railway
OAuth2 Proxy is an open-source reverse proxy that puts a login in front of web apps that have none. It signs users in with Google, GitHub, Microsoft Entra ID, GitLab or any OpenID Connect provider, checks their email domain, and only then forwards requests to the app behind it.
About Hosting OAuth2 Proxy
This template runs OAuth2 Proxy v7.15.6 as one stateless service built from a small GitHub wrapper around the official image. Sessions are kept in encrypted cookies, so it needs no database or volume. It is meant to sit in front of a service that already runs in your Railway project: point OAUTH2_PROXY_UPSTREAMS at that service over the private network, give users the proxy's public domain instead of the app's, and remove the app's own public domain. You register an OAuth app with your identity provider, using https://YOUR-DOMAIN/oauth2/callback as the callback URL, and paste its client ID and secret.
Common Use Cases
- Add Google Workspace or GitHub login to an internal dashboard, admin panel or staging site
- Restrict a tool with no built-in auth (Grafana-style dashboards, docs, Jupyter, a Streamlit app) to your company's email domain
- Put single sign-on from Keycloak, Authentik or another OIDC provider in front of several services
Dependencies for OAuth2 Proxy Hosting
- An OAuth app (client ID and secret) at your identity provider
- A web service in the same Railway project to protect
Deployment Dependencies
- OAuth2 Proxy: https://github.com/oauth2-proxy/oauth2-proxy (release v7.15.6)
- Documentation: https://oauth2-proxy.github.io/oauth2-proxy/
- Provider setup guides: https://oauth2-proxy.github.io/oauth2-proxy/configuration/providers/
- Template source: https://github.com/aalfath/oauth2-proxy-railway-template
Implementation Details
Set these when you deploy:
OAUTH2_PROXY_UPSTREAMS: the service to protect, for examplehttp://${{web.RAILWAY_PRIVATE_DOMAIN}}:${{web.PORT}}(replacewebwith your service's name; use a literal port if that service has noPORTvariable)OAUTH2_PROXY_PROVIDER:googleby default;github,entra-id,gitlab,oidcand others work tooOAUTH2_PROXY_CLIENT_IDandOAUTH2_PROXY_CLIENT_SECRET: from your provider's OAuth appOAUTH2_PROXY_EMAIL_DOMAINS: allowed domains, comma-separated, such asexample.com;*allows any account the provider signs inOAUTH2_PROXY_OIDC_ISSUER_URL: only for theoidcprovider
The cookie secret is generated. The callback URL follows the service's Railway domain automatically; if you add a custom domain, set OAUTH2_PROXY_REDIRECT_URL=https://YOUR-DOMAIN/oauth2/callback. The signed-in user reaches your app in the X-Forwarded-User and X-Forwarded-Email headers. Any other setting can be added as an OAUTH2_PROXY_* variable, for example OAUTH2_PROXY_GITHUB_ORG to limit GitHub logins to one organisation. The health check is /ping. Updates to the template repo show up as "update available" in your project.
Why Deploy OAuth2 Proxy on Railway?
Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.
By deploying OAuth2 Proxy on Railway, you are one step closer to supporting a complete full-stack application with minimal burden. Host your servers, databases, AI agents, and more on Railway.
Template Content
oauth2-proxy
aalfath/oauth2-proxy-railway-templateOAUTH2_PROXY_CLIENT_ID
OAuth client ID from your provider. Callback URL: https://YOUR-DOMAIN/oauth2/callback
OAUTH2_PROXY_UPSTREAMS
Service to protect, over the private network, e.g. http://${{web.RAILWAY_PRIVATE_DOMAIN}}:${{web.PORT}}
OAUTH2_PROXY_CLIENT_SECRET
OAuth client secret from your provider
OAUTH2_PROXY_EMAIL_DOMAINS
Allowed email domains, comma-separated (example.com). * allows any account the provider signs in

