I am using thomseddon/traefik-forward-auth
and google to auth access to my homelab services over https.
For Plex this breaks remote access, as the clients are not web browsers.
How can I add exclusions for some domains to bypass auth?
(Fyi; I run two docker instances of traefik, one for internal access with no auth, and one bound to a port forwarded address with auth on all services. I also run a wildcard DNS, so I can access any internal service directly at foo.home.bar.net, and via auth port forwarded at foo.service.bar.net, where *.service.bar.net is a wildcard pointing to my public IP)
Traefik config in Ansible:
---
# Install Traefik Forward Auth
# https://hub.docker.com/r/thomseddon/traefik-forward-auth
# https://www.github.com/thomseddon/traefik-forward-auth
# https://docs.traefik.io/middlewares/forwardauth/
# https://docs.ansible.com/ansible/latest/collections/community/docker/docker_container_module.html
- name: "Install Traefik Forward Auth"
community.docker.docker_container:
name: traefik-forward-auth
image: thomseddon/traefik-forward-auth:latest
pull: yes
hostname: "traefik-forward-auth-{{ ansible_hostname }}"
domainname: "{{ ansible_domain }}"
restart_policy: unless-stopped
user: "{{ user_id }}:{{ group_id }}"
env:
TZ: "{{ local_timezone }}"
DEFAULT_PROVIDER: "google"
PROVIDERS_GOOGLE_CLIENT_ID: "{{ google_auth_id }}"
PROVIDERS_GOOGLE_CLIENT_SECRET: "{{ google_auth_secret }}"
SECRET: "{{ traefik_auth_secret }}"
COOKIE_DOMAIN: "{{ external_domain }}"
#LOG_LEVEL: "debug"
WHITELIST: "{{ traefik_auth_allow }}"
AUTH_HOST: "{{ traefik_auth_server }}"
networks:
- name: "{{ docker_local_network }}"
# published_ports:
# External routing via traefik
# - 4181:4181
labels:
traefik.enable: "true"
traefik.http.routers.traefik-forward-auth.rule: "Host(`{{ traefik_auth_server }}`)"
traefik.http.routers.traefik-forward-auth.entrypoints: "websecure"
traefik.http.routers.traefik-forward-auth.middlewares: "traefik-forward-auth"
traefik.http.middlewares.traefik-forward-auth.forwardauth.address: "http://traefik-forward-auth:4181"
traefik.http.middlewares.traefik-forward-auth.forwardauth.authresponseheaders: "X-Forwarded-User"
# Manually specify port and schema
traefik.http.services.traefik-forward-auth.loadbalancer.server.port: "4181"
traefik.http.services.traefik-forward-auth.loadbalancer.server.scheme: "http"
com.centurylinklabs.watchtower.enable: "true"
recreate: "{{ docker_container_recreate }}"
Traeefik config file:
global:
sendAnonymousUsage: true
log:
level: "WARN" # DEBUG, PANIC, FATAL, ERROR, WARN, and INFO
api:
dashboard: true
insecure: true # Enable dashboard on http 8080 for direct access
serversTransport:
insecureSkipVerify: true # Ignore downstream SSL cert errors
providers:
docker:
exposedByDefault: false
network: "localnet" # {{ docker_local_network }}
file:
filename: "/config/dynamic-public.yml"
# https://docs.traefik.io/routing/entrypoints/
entryPoints:
ssh:
address: ":2022"
web:
address: ":80"
http:
redirections:
entryPoint:
to: websecure
scheme: https
websecure:
address: ":443"
http:
tls:
domains:
- main: "service.insanegenius.net"
sans:
- "*.service.insanegenius.net"
- main: "home.insanegenius.net"
sans:
- "*.home.insanegenius.net"
- main: "insanegenius.net"
sans:
- "*.insanegenius.net"
middlewares:
# Enable auth for all services
- "traefik-forward-auth@docker"
Forward auth:
---
# Install Traefik Forward Auth
# https://hub.docker.com/r/thomseddon/traefik-forward-auth
# https://www.github.com/thomseddon/traefik-forward-auth
# https://docs.traefik.io/middlewares/forwardauth/
# https://docs.ansible.com/ansible/latest/collections/community/docker/docker_container_module.html
- name: "Install Traefik Forward Auth"
community.docker.docker_container:
name: traefik-forward-auth
image: thomseddon/traefik-forward-auth:latest
pull: yes
hostname: "traefik-forward-auth-{{ ansible_hostname }}"
domainname: "{{ ansible_domain }}"
restart_policy: unless-stopped
user: "{{ user_id }}:{{ group_id }}"
env:
TZ: "{{ local_timezone }}"
DEFAULT_PROVIDER: "google"
PROVIDERS_GOOGLE_CLIENT_ID: "{{ google_auth_id }}"
PROVIDERS_GOOGLE_CLIENT_SECRET: "{{ google_auth_secret }}"
SECRET: "{{ traefik_auth_secret }}"
COOKIE_DOMAIN: "{{ external_domain }}"
#LOG_LEVEL: "debug"
WHITELIST: "{{ traefik_auth_allow }}"
AUTH_HOST: "{{ traefik_auth_server }}"
networks:
- name: "{{ docker_local_network }}"
# published_ports:
# External routing via traefik
# - 4181:4181
labels:
traefik.enable: "true"
traefik.http.routers.traefik-forward-auth.rule: "Host(`{{ traefik_auth_server }}`)"
traefik.http.routers.traefik-forward-auth.entrypoints: "websecure"
traefik.http.routers.traefik-forward-auth.middlewares: "traefik-forward-auth"
traefik.http.middlewares.traefik-forward-auth.forwardauth.address: "http://traefik-forward-auth:4181"
traefik.http.middlewares.traefik-forward-auth.forwardauth.authresponseheaders: "X-Forwarded-User"
# Manually specify port and schema
traefik.http.services.traefik-forward-auth.loadbalancer.server.port: "4181"
traefik.http.services.traefik-forward-auth.loadbalancer.server.scheme: "http"
com.centurylinklabs.watchtower.enable: "true"
recreate: "{{ docker_container_recreate }}"
I suspect I need to add exclusion to the middlewares, but I've not found info on how?
middlewares:
# Enable auth for all services
- "traefik-forward-auth@docker"