---
title: "Deploy OAuth2 Proxy"
description: "OAuth2 Proxy 7.15: Google, GitHub or OIDC login in front of any service"
category: "Authentication"
url: https://railway.com/deploy/oauth2-proxy
---

# Deploy OAuth2 Proxy

OAuth2 Proxy 7.15: Google, GitHub or OIDC login in front of any service

**[Deploy OAuth2 Proxy on Railway](https://railway.com/template/oauth2-proxy)**

Machine-readable deploy manifest (JSON, validated by TemplateCI): https://railway.com/deploy/oauth2-proxy/manifest.json

- **Creator:** Agaz Self-Host
- **Category:** Authentication

## Template content

### oauth2-proxy https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons/png/oauth2-proxy.png

- **Source:** https://github.com/aalfath/oauth2-proxy-railway-template
- **Health check:** /ping
- **Public domain:** Yes

## Documentation

# 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 example `http://${{web.RAILWAY_PRIVATE_DOMAIN}}:${{web.PORT}}` (replace `web` with your service's name; use a literal port if that service has no `PORT` variable)
* `OAUTH2_PROXY_PROVIDER`: `google` by default; `github`, `entra-id`, `gitlab`, `oidc` and others work too
* `OAUTH2_PROXY_CLIENT_ID` and `OAUTH2_PROXY_CLIENT_SECRET`: from your provider's OAuth app
* `OAUTH2_PROXY_EMAIL_DOMAINS`: allowed domains, comma-separated, such as `example.com`; `*` allows any account the provider signs in
* `OAUTH2_PROXY_OIDC_ISSUER_URL`: only for the `oidc` provider

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.



## Similar templates

- [Keycloak](https://railway.com/deploy/mSwigX) — [2026-11-04] Keycloak with keywind theme + Apple & Discord providers
- [lua-protector](https://railway.com/deploy/lua-protector) — Test deployed my project first
- [bknd](https://railway.com/deploy/p4nTYL) — Feature-rich yet lightweight backend

Open this page in a browser: https://railway.com/deploy/oauth2-proxy
