我的家庭媒体服务器使用单个docker compose文件建立了一个可以运行的docker stack:
version: "3"
secrets:
authelia_jwt_secret:
file: $SECRETS_PATH/authelia/jwt_secret
authelia_session_secret:
file: $SECRETS_PATH/authelia/session_secret
services:
calibre-web:
image: linuxserver/calibre-web:nightly
container_name: calibre-web
environment:
- PUID=$PUID
- PGID=$PGID
labels:
- traefik.enable=true
- traefik.http.routers.calibre-https.rule=Host(`books.pointerstop.ca`)
- traefik.http.routers.calibre-https.middlewares=authelia@file
- traefik.http.routers.calibre-https.tls=true
- traefik.http.routers.calibre-https.tls.certresolver=letsencrypt
volumes:
- /srv/calibre/config/calibre-web:/config
- /srv/calibre/CalibreLibrary:/Calibre_Library up
restart: unless-stopped
depends_on:
- calibre
expose:
- 8083
traefik:
image: traefik:latest
container_name: traefik
restart: unless-stopped
command:
- --api.insecure=true
- --providers.docker
- --entrypoints.web.address=:80
- --entrypoints.websecure.address=:443
- --certificatesresolvers.letsencrypt.acme.email=${LE_EMAIL}
- --certificatesresolvers.letsencrypt.acme.storage=/config/acme.json
- --certificatesresolvers.letsencrypt.acme.tlschallenge=true
# - --certificatesresolvers.letsencrypt.acme.caserver=https://acme-staging-v02.api.letsencrypt.org/directory
- --log.filePath=/var/log/traefik.log
- --log.level=DEBUG
- --providers.file.directory=/dynamic_config/
- --providers.file.watch=true
ports:
- 8080:8080
- 80:80
- 443:443
labels:
- traefik.enable=true
- traefik.http.routers.traefik.rule=Host(`traefik.local`)
## Services - API
- traefik.http.routers.traefik.service=api@internal
## Global redirect of EXTERNAL domains to HTTPS
- traefik.http.routers.redirs.rule=hostregexp(`{host:.*pointerstop.ca}`)
- traefik.http.routers.redirs.entrypoints=web
- traefik.http.routers.redirs.middlewares=redirect-to-https@file
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /var/log/media-server:/var/log
- ${CONFIG_PATH}/traefik:/config
- ./dynamic_config:/dynamic_config
# Authelia (Lite) - Self-Hosted Single Sign-On and Two-Factor Authentication
authelia:
container_name: authelia
image: authelia/authelia:latest
# image: authelia/authelia:4.21.0
restart: always
expose:
- 9091
volumes:
- $CONFIG_PATH/authelia:/config
environment:
- TZ=${TIME_ZONE}
- AUTHELIA_JWT_SECRET_FILE=/run/secrets/authelia_jwt_secret
- AUTHELIA_SESSION_SECRET_FILE=/run/secrets/authelia_session_secret
secrets:
- authelia_jwt_secret
- authelia_session_secret
labels:
- traefik.enable=true
## HTTP Routers
- traefik.http.routers.authelia-rtr.entrypoints=websecure
- traefik.http.routers.authelia-rtr.rule=Host(`auth.pointerstop.ca`)
- traefik.http.routers.authelia-rtr.tls=true
- traefik.http.routers.authelia-rtr.tls.certresolver=letsencrypt
## Middlewares
- traefik.http.routers.authelia-rtr.middlewares=chain-authelia@file
## HTTP Services
- traefik.http.services.authelia-media-server.loadbalancer.server.port=9091
现在,我想将代理分离到一个单独的堆栈中,以便我可以在第三个堆栈中添加我的业务域,并让所有内容受到 Authelia 保护。
因此,我创建了一个 docker 网络proxy
,并且一切都使用该网络,除了使用 Authelia 进行身份验证后,其他一切都完全成功https://books.pointerstop.ca/(Calibre-web) 想要再次进行身份验证。
我知道我需要entrypoints.websecure.forwardedHeaders.trustedIPs
在 Traefik 中设置,否则 Traefik 会删除所有重要的标头,但我不知道它们应该是什么。由于所有内容都在同一个 docker 堆栈中,我根本不需要信任 IP。现在它们在不同的堆栈中,但在同一个网络上,我不明白发生了什么变化。我尝试设置trustedIPs=172.0.0.0/8
覆盖所有docker网络。*.pointerstop.ca
是CNAME到pointerstop.ddns.net
,并且唯一报告的IP在https://books.pointerstop.ca/login是我的外部 IP——但是在单栈设置中不需要它时,要求它似乎是错误的(并且它是动态分配的,使用起来很不方便)。