I am using traefik to handle reverse proxy and redirects subdomains to a specific port with the load balancer, using:
traefik.yml
#snipped extraneous parts
providers:
docker:
endpoint: "unix:///var/run/docker.sock"
exposedByDefault: false
file:
filename: /etc/traefik/routes.yml
watch: true
docker-compose.yml
#snipped extraneous parts
services:
traefik:
container_name: traefik
image: traefik
restart: always
hostname: traefik
domainname: ${DUCKDNS_DOMAIN}
networks:
- default
- traefik_proxy
ports:
- "9080:80"
- "9443:443"
environment:
- DUCKDNS_TOKEN # Pass through to container
labels:
- "traefik.enable=true"
- "traefik.docker.network=traefik_proxy"
- "traefik.http.routers.traefik.entrypoints=http"
- "traefik.http.routers.traefik.rule=Host(`traefik.${DUCKDNS_DOMAIN}`)"
- "traefik.http.routers.traefik.middlewares=traefik-https-redirect"
- "traefik.http.routers.traefik-secure.entrypoints=https"
- "traefik.http.routers.traefik-secure.rule=Host(`traefik.${DUCKDNS_DOMAIN}`)"
- "traefik.http.routers.traefik-secure.middlewares=traefik-auth"
- "traefik.http.routers.traefik-secure.tls=true"
- "traefik.http.routers.traefik-secure.tls.certresolver=duckdns"
- "traefik.http.routers.traefik-secure.service=api@internal"
- "traefik.http.routers.traefik-secure.tls.domains[0].main=${DUCKDNS_DOMAIN}"
- "traefik.http.routers.traefik-secure.tls.domains[0].sans=*.${DUCKDNS_DOMAIN}"
- "traefik.http.middlewares.traefik-auth.basicauth.users=${HTTP_USERNAME}:${HTTP_PASSWORD}"
- "traefik.http.middlewares.traefik-https-redirect.redirectscheme.scheme=https"
volumes:
- '/var/run/docker.sock:/var/run/docker.sock:ro'
- '${DOCKER_DIR}/traefik:/etc/traefik'
- '${DOCKER_DIR}/shared:/share'
home-assistant:
image: homeassistant/raspberrypi3-homeassistant
container_name: home-assistant
restart: always
depends_on:
- portainer
volumes:
- '${DOCKER_DIR}/homeassistant:/config'
- '/etc/localtime:/etc/localtime:ro'
networks:
- traefik_proxy
ports:
- '8123:8123' # Allow connection from local network
labels:
- "traefik.enable=true"
- "traefik.docker.network=traefik_proxy"
- "traefik.http.routers.home-assistant.entrypoints=http"
- "traefik.http.routers.home-assistant.rule=Host(`ha.${DUCKDNS_DOMAIN}`)"
- "traefik.http.routers.home-assistant.middlewares=home-assistant-https-redirect"
- "traefik.http.routers.home-assistant-secure.entrypoints=https"
- "traefik.http.routers.home-assistant-secure.rule=Host(`ha.${DUCKDNS_DOMAIN}`)"
- "traefik.http.routers.home-assistant-secure.tls=true"
- "traefik.http.routers.home-assistant-secure.tls.certresolver=duckdns"
- "traefik.http.routers.home-assistant-secure.service=home-assistant"
- "traefik.http.middlewares.home-assistant-https-redirect.redirectscheme.scheme=https"
- "traefik.http.services.home-assistant.loadbalancer.server.port=8123"
- "traefik.http.routers.sonarr.entrypoints=http"
- "traefik.http.routers.sonarr.rule=Host(`sonarr.${DUCKDNS_DOMAIN}`)"
- "traefik.http.routers.sonarr.middlewares=sonarr-https-redirect"
- "traefik.http.routers.sonarr-secure.entrypoints=https"
- "traefik.http.routers.sonarr-secure.rule=Host(`sonarr.${DUCKDNS_DOMAIN}`)"
- "traefik.http.routers.sonarr-secure.middlewares=sonarr-auth"
- "traefik.http.routers.sonarr-secure.tls=true"
- "traefik.http.routers.sonarr-secure.tls.certresolver=duckdns"
- "traefik.http.routers.sonarr-secure.service=sonarr@file"
- "traefik.http.routers.sonarr-secure.tls.domains[0].main=${DUCKDNS_DOMAIN}"
- "traefik.http.routers.sonarr-secure.tls.domains[0].sans=*.${DUCKDNS_DOMAIN}"
- "traefik.http.middlewares.sonarr-auth.basicauth.users=${HTTP_USERNAME}:${HTTP_PASSWORD}"
- "traefik.http.middlewares.sonarr-https-redirect.redirectscheme.scheme=https"
networks:
traefik_proxy:
external: false
name: traefik_proxy
default:
driver: bridge
routes.yml
http:
services:
sonarr:
loadBalancer:
servers:
- url: "http://192.168.1.123:8989"
https:
services:
sonarr:
loadBalancer:
servers:
- url: "https://192.168.1.123:8989"
The "ha" subdomain works perfectly.
The "sonarr" subdomain (for the LAN IP address) just gives me, 404 page not found
.
I have tried not using redirection of http to https with the same result.
I think I am missing something. Help gratefully received.