November 6, 2024, 11:54
services: traefik: container_name: traefik image: traefik:v3.0 restart: always ports: - 80:80 - 443:443 - 8080:8080 volumes: - /var/run/docker.sock:/var/run/docker.sock:ro - ./traefik.yml:/etc/traefik/traefik.yml - ./acme.json:/acme.json networks: - traefikproxy networks: traefikproxy: external: true name: traefikproxytraefik.yml
entryPoints: web: address: ":80" http: redirections: entryPoint: to: websecure scheme: https websecure: address: ":443" api: dashboard: true insecure: true providers: docker: exposedByDefault: false network: traefikproxy certificatesResolvers: letsencrypt: acme: email: [email protected] storage: acme.json httpChallenge: entryPoint: webdynamic.yml
http: middlewares: secHeaders: headers: browserXssFilter: true contentTypeNosniff: true frameDeny: true sslRedirect: true #HSTS Configuration stsIncludeSubdomains: true stsPreload: true stsSeconds: 31536000 customFrameOptionsValue: "SAMEORIGIN" https-redirect: redirectScheme: scheme: httpssudo docker network create -d bridge traefikproxy You must add the following to the other container in compose.yml.
labels: - "traefik.enable=true" - "traefik.http.routers.XXX.rule=Host(YYY)" - "traefik.http.routers.XXX.entrypoints=websecure" - "traefik.http.routers.XXX.tls=true" - "traefik.http.routers.XXX.tls.certresolver=letsencrypt"
labels: - "traefik.enable=true " - "traefik.http.routers.mosquitto.rule=Host(YYY)" - "traefik.http.routers.mosquitto.entrypoints=websecure " - "traefik.http.routers.mosquitto.tls=true " - "traefik.http.routers.mosquitto.tls.certresolver=letsencrypt"For YYY you have to set the domain. And you must add the network to the containers that are to be accessible via the domain.
networks: - traefikproxy networks: default: traefikproxy: external: true name: traefikproxyMy grafana compose.yml, for example, looks like this:
services: grafana: image: grafana/grafana:latest container_name: grafana restart: unless-stopped environment: - GF_SERVER_ROOT_URL=https://grafana.example.com - GF_AUTH_ANONYMOUS_ENABLED=true - TZ=Europe/Berlin ports: - 3000:3000 volumes: - grafana_storage:/var/lib/grafana labels: - "traefik.enable=true" - "traefik.http.routers.grafana.rule=Host(grafana.example.com)" - "traefik.http.routers.grafana.entrypoints=websecure" - "traefik.http.routers.grafana.tls=true" - "traefik.http.routers.grafana.tls.certresolver=letsencrypt" networks: - node-red-net - traefikproxy networks: node-red-net: external: true name: node-red-net traefikproxy: external: true name: traefikproxy volumes: grafana_storage: {}