-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtraefik-oauth.yml
66 lines (60 loc) · 2.53 KB
/
traefik-oauth.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
version: "3.3"
#
# This file enables SSO via Google Cloud OAUTH. Additionally, it layers in rate limiting.
#
# @credit https://www.smarthomebeginner.com/google-oauth-with-traefik-2-docker/
#
services:
traefik:
labels:
# -----------------------------
# Define reusable middlewares
# -----------------------------
- traefik.http.middlewares.sso.forwardauth.address=http://oauth:4181
- traefik.http.middlewares.sso.forwardauth.trustForwardHeader=true
- traefik.http.middlewares.sso.forwardauth.authResponseHeaders=X-Forwarded-User
# rate limit
- traefik.http.middlewares.rate-limit.rateLimit.average=100
- traefik.http.middlewares.rate-limit.rateLimit.burst=50
# -----------------------------
# Define chain
# -----------------------------
- traefik.http.middlewares.chain-oauth.chain.middlewares=rate-limit,sso
- traefik.http.middlewares.chain-no-auth.chain.middlewares=rate-limit
# -----------------------------
# Apply middlewares to dashboard UI
# -----------------------------
- traefik.http.routers.traefik.middlewares=chain-oauth@docker
oauth:
restart: unless-stopped
container_name: oauth
image: thomseddon/traefik-forward-auth
# Allow apps to bypass OAuth. Radarr example below will bypass OAuth if API key is present in the request (eg. from NZB360 mobile app).
# While this is one way, the recommended way is to bypass authentication using Traefik labels shown in some of the apps later.
# command: --rule.radarr.action=allow --rule.radarr.rule=Headers(`X-Api-Key`, `$RADARR_API_KEY`)
# command: --rule.sabnzbd.action=allow --rule.sabnzbd.rule=HeadersRegexp(`X-Forwarded-Uri`, `$SABNZBD_API_KEY`)
environment:
- PROVIDERS_GOOGLE_CLIENT_ID=${GCP_OAUTH_CLIENT_ID}
- PROVIDERS_GOOGLE_CLIENT_SECRET=${GCP_OAUTH_CLIENT_SECRET}
- SECRET=${OAUTH_SECRET}
- COOKIE_DOMAIN=${DOMAIN}
- AUTH_HOST=oauth.${DOMAIN}
- URL_PATH=${OAUTH_PATH}
- LOG_LEVEL=debug
- LOG_FORMAT=pretty
labels:
- traefik.enable=true
# -----------------------------
# HTTP Routers
# -----------------------------
- traefik.http.routers.oauth.entrypoints=https
# -----------------------------
# HTTP Services
# -----------------------------
- traefik.http.services.oauth.loadbalancer.server.port=4181
- traefik.http.routers.oauth.service=oauth
networks:
- web
whoami:
labels:
- traefik.http.routers.whoami.middlewares=chain-oauth@docker