Bad gateway - Cannot get Traefik to work with one container

I recently updated my Domoticz docker. After the update, I cannot get the Traefik proxy to work, and I'm out of ideas on how to find the root cause. I can access other containers just fine, but not this particular one.

I have tried to remove and recreate the network - what would be the next step for troubleshooting?

On accessing <url.com>, I get a 502 Bad gateway. I can access using http://local-ip:8080 and https://local-ip:1443.

Does it have to do with the lines in the log containing Status: WebServer(HTTP) startup failed on address?

Traefik v2.2. Ubuntu 20.04.3 LTS.

Traefik access log:

192.168.1.1 - - [02/Sep/2021:08:04:51 +0000] "GET / HTTP/2.0" 502 11 "-" "-" 1432 "home@docker" "http://172.18.0.2:443" 0ms
192.168.1.1 - - [02/Sep/2021:08:04:52 +0000] "GET /favicon.ico HTTP/2.0" 502 11 "-" "-" 1433 "home@docker" "http://172.18.0.2:443" 0ms

Here are my config files:

Domoticz docker-compose.yml

version: '3'
services:
  domoticz:
    container_name: domoticz
    image: domoticz/domoticz:latest
    restart: unless-stopped
    volumes:
      - /home/user/docker-data/domoticz/build/keys:/config/keys
      - /home/user/docker-data/domoticz/data:/opt/domoticz/userdata
    privileged: true
    labels:
      - traefik.http.routers.home.rule=Host(`url.com`)
      - traefik.http.routers.home.tls=true
      - traefik.http.routers.home.tls.certresolver=lets-encrypt
      - traefik.port=8080
    ports:
      - '8080:8080'
      - '6144:6144'
      - '1443:443'
    environment:
      - TZ=Europe/Stockholm
      - PUID=1000
      - PGID=1000
    tty: true
    devices:
      - /dev/ttyACM0:/dev/ttyACM0
      - /dev/ttyUSB0:/dev/ttyUSB0
    networks:
      - web

networks:
  web:
    external: true

I start Traefik with this command:

docker run -d \
  -v /var/run/docker.sock:/var/run/docker.sock \
  -v $PWD/traefik.toml:/traefik.toml \
  -v $PWD/traefik_dynamic.toml:/traefik_dynamic.toml \
  -v $PWD/acme.json:/acme.json \
  -p 80:80 \
  -p 443:443 \
  --network web \
  --name traefik \
  traefik:v2.2

Traefik traefik.toml

[entryPoints]
  [entryPoints.web]
    address = ":80"
    [entryPoints.web.http.redirections.entryPoint]
      to = "websecure"
      scheme = "https"

  [entryPoints.websecure]
    address = ":443"

[api]
  dashboard = true

[certificatesResolvers.lets-encrypt.acme]
  email = "my-email@domain.com"
  storage = "acme.json"
  [certificatesResolvers.lets-encrypt.acme.tlsChallenge]

[providers.docker]
  watch = true
  network = "web"

[providers.file]
  filename = "traefik_dynamic.toml"

[accessLog]

Domoticz Start-up log

domoticz    | 2021-09-02 10:10:42.570  Status: Domoticz V2021.1 (build 13422) (c)2012-2021 GizMoCuz
domoticz    | 2021-09-02 10:10:42.570  Status: Build Hash: 56d1c95a0, Date: 2021-08-16 13:41:21
domoticz    | 2021-09-02 10:10:42.570  Status: Startup Path: /opt/domoticz/
domoticz    | 2021-09-02 10:10:42.620  Sunrise: 05:48:00 SunSet: 19:48:00
domoticz    | 2021-09-02 10:10:42.620  Day length: 13:59:00 Sun at south: 12:48:00
domoticz    | 2021-09-02 10:10:42.620  Civil twilight start: 05:05:00 Civil twilight end: 20:31:00
domoticz    | 2021-09-02 10:10:42.620  Nautical twilight start: 04:09:00 Nautical twilight end: 21:27:00
domoticz    | 2021-09-02 10:10:42.620  Astronomical twilight start: 03:00:00 Astronomical twilight end: 22:36:00
domoticz    | 2021-09-02 10:10:42.928  Status: PluginSystem: Started, Python version '3.7.3'.
domoticz    | 2021-09-02 10:10:42.932  Active notification Subsystems: fcm (1/13)
domoticz    | 2021-09-02 10:10:42.993  Status: WebServer(HTTP) startup failed on address :: with port: 8080: resolve: Host not found (authoritative), trying ::
domoticz    | 2021-09-02 10:10:42.994  Status: WebServer(HTTP) startup failed on address :: with port: 8080: resolve: Host not found (authoritative), trying 0.0.0.0
domoticz    | 2021-09-02 10:10:42.995  Status: WebServer(HTTP) started on address: 0.0.0.0 with port 8080
domoticz    | 2021-09-02 10:10:43.042  Status: WebServer(SSL) startup failed on address :: with port: 443: resolve: Host not found (authoritative), trying ::
domoticz    | 2021-09-02 10:10:43.043  Status: WebServer(SSL) startup failed on address :: with port: 443: resolve: Host not found (authoritative), trying 0.0.0.0
domoticz    | 2021-09-02 10:10:43.044  Status: WebServer(SSL) started on address: 0.0.0.0 with port 443
domoticz    | 2021-09-02 10:10:43.045  Starting shared server on: 0.0.0.0:6144
domoticz    | 2021-09-02 10:10:43.045  Status: TCPServer: shared server started...
domoticz    | 2021-09-02 10:10:43.045  Status: RxQueue: queue worker started...
domoticz    | 2021-09-02 10:10:45.046  Status: RFXtrx433E: Worker started...
domoticz    | 2021-09-02 10:10:45.046  Status: Arilux: Worker started...
domoticz    | 2021-09-02 10:10:45.046  Status: NotificationSystem: thread started...
domoticz    | 2021-09-02 10:10:45.052  Status: EventSystem: reset all events...
domoticz    | 2021-09-02 10:10:45.053  Status: dzVents: Write file: /opt/domoticz/userdata/scripts/dzVents/generated_scripts/LedLights.lua
domoticz    | 2021-09-02 10:10:45.053  Error: EventSystem: problem writing file: /opt/domoticz/userdata/scripts/dzVents/generated_scripts/LedLights.lua
domoticz    | 2021-09-02 10:10:45.054  Status: EventSystem: reset all device statuses...
domoticz    | 2021-09-02 10:10:45.081  Status: Python EventSystem: Initializing event module.
domoticz    | 2021-09-02 10:10:45.082  Status: EventSystem: Started

I see in the traefik logs that traffic is directed to http://172.18.0.2:443 which doesn't make sense. Should be http://172.18.0.2:8080 according to config. Why is that?

Hi @jslettengren

This should be: traefik.http.services.my-service.loadbalancer.server.port=8080

image

1 Like

Thanks a lot! This saved me. Now on to all other (non-traefik-related) errors I have :slight_smile:

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.