ldellisola / TraefikKobling

A dynamic Traefik-to-Traefik discovery agent
MIT License
60 stars 2 forks source link

Gateway Timeout issue #22

Closed mregni closed 1 year ago

mregni commented 1 year ago

Thanks for the fast entrypoint fix!

I tried your new solution and it seems to be working (config in traefik looks good) but I always get a Gateway Timeout when I call a service on my sub machine.

MAIN docker compose:

version: '3.9'
services:
  traefik:
    container_name: traefik
    image: traefik:${TRAEFIK_IMAGE_TAG}
    networks:
      - net
    security_opt:
      - no-new-privileges:true
    restart: always
    environment:
      - TZ=${TZ}
      - CF_API_EMAIL=${CLOUDFLARE_EMAIL}
      - CF_API_KEY=${CLOUDFLARE_API_KEY}
    volumes:
      - ...
    ports:
      - 80:80
      - 443:443
      - ${TRAEFIK_DASHBOARD_PORT}:8080
    depends_on:
      - redis
    labels:
      - traefik.enable=true
      - traefik.http.routers.traefik-rtr.entrypoints=websecure
      - traefik.http.routers.traefik-rtr.rule=Host(`traefik.$DOMAINNAME_CLOUD_SERVER`)
      - traefik.http.routers.traefik-rtr.tls=true
      - traefik.http.routers.traefik-rtr.middlewares=chain-local@file
      - traefik.http.routers.traefik-rtr.service=api@internal

  traefik-kobling:
    image: ghcr.io/ldellisola/traefik-kobling
    container_name: traefik-connector
    volumes:
      - /cat/docker/volumes/network_traefik_kobling/config.yml:/config.yml
    environment:
      REDIS_URL: "network_redis:6379"
    depends_on:
      - redis
    networks:
      - net

networks:
  net:
    driver: bridge

traefik-kobling config file

servers:
  - name: "jupiter"
    apiAddress: http://jupiter:8080
    destinationAddress: http://192.168.72.255
    entryPoints:
      websecure: web

Main Traefik dashboard image image

Main Debug logging:

time="2023-04-25T11:01:08+02:00" level=debug msg="'504 Gateway Timeout' caused by: dial tcp 192.168.72.255:80: i/o timeout"
time="2023-04-25T11:01:09+02:00" level=debug msg="Configuration received: {\"http\":{\"routers\":{\"api_jupiter\":{\"entryPoints\":[\"websecure\"],\"service\":\"jupiter\",\"rule\":\"Host(`jupiter.domain.tld`)\"},\"dashboard_jupiter\":{\"service\":\"jupiter\",\"rule\":\"PathPrefix(`/`)\"},\"uptime-kuma-rtr\":{\"entryPoints\":[\"websecure\"],\"service\":\"jupiter\",\"rule\":\"Host(`statusdomain.tld`)\"},\"whoami-rtr\":{\"entryPoints\":[\"websecure\"],\"service\":\"jupiter\",\"rule\":\"Host(`whoami.domain.tld`)\"}},\"services\":{\"jupiter\":{\"loadBalancer\":{\"servers\":[{\"url\":\"http://192.168.72.255/\"}],\"passHostHeader\":true}}}},\"tcp\":{},\"udp\":{}}" providerName=redis
time="2023-04-25T11:01:09+02:00" level=debug msg="Skipping unchanged configuration." providerName=redis
time="2023-04-25T11:23:48+02:00" level=debug msg="'504 Gateway Timeout' caused by: dial tcp 192.168.72.255:80: i/o timeout"
time="2023-04-25T11:33:51+02:00" level=debug msg="'504 Gateway Timeout' caused by: dial tcp 192.168.72.255:80: i/o timeout"
time="2023-04-25T11:45:24+02:00" level=debug msg="Serving default certificate for request: \"\""
time="2023-04-25T11:45:24+02:00" level=debug msg="Serving default certificate for request: \"\""
time="2023-04-25T11:45:24+02:00" level=debug msg="Serving default certificate for request: \"\""
time="2023-04-25T11:45:34+02:00" level=debug msg="'499 Client Closed Request' caused by: context canceled"
time="2023-04-25T11:45:34+02:00" level=debug msg="Serving default certificate for request: \"\""
time="2023-04-25T11:53:48+02:00" level=debug msg="'504 Gateway Timeout' caused by: dial tcp 192.168.72.255:80: i/o timeout"

Sub machine docker compose:

version: '3.9'
services:
  traefik:
    image: traefik:$TRAEFIK_IMAGE_TAG
    container_name: traefik
    restart: always
    security_opt:
      - no-new-privileges:true
    ports:
      - 80:80
      - 8080:8080
    environment:
      - TZ=${TZ}
    volumes:
      - /home/reggi/volumes/network_traefik/logs:/logs
    labels:
      - traefik.enable=true
      - traefik.http.routers.traefik.rule=Host(`jupiter.$DOMAINNAME_CLOUD_SERVER`)
      - traefik.http.routers.traefik.service=api@internal
      - traefik.http.services.traefik.loadbalancer.server.port=8080
    command: 
      - --api=true
      - --api.insecure=true

      - --log.filePath=/logs/traefik.log
      - --log.level=DEBUG

      - --entryPoints.web.address=:80

      - --providers.docker=true
      - --providers.docker.endpoint=unix:tcp://dockerproxy:2375
      - --providers.docker.exposedByDefault=false
      - --providers.docker.network=network_network
    networks:
      - network

  whoami:
    image: traefik/whoami
    container_name: whoami
    restart: always
    networks:
      - network
    ports:
      - 2001:2001
    command:
      - --port=2001
    labels:
      - traefik.enable=true
      - traefik.http.routers.whoami-rtr.rule=Host(`whoami.$DOMAINNAME_CLOUD_SERVER`)
      - traefik.http.routers.whoami-router.entrypoints=web
      - traefik.http.services.whoami-rtr.loadbalancer.server.port=2001

  dockerproxy:
    ...

networks:
  network:
    driver: bridge

sub traefik dashboard image

I'm not sure what is happening. I can see a gateway timeout on my main machine but nothing on my sub machine meaning the call to 192.168.72.225:80 is failing. Any idea why?

Ow, if I navigate to the whoami service directly, there is no issue. So it's not the docker service itself. Maybe I'm doing something wrong with the setup between the main and sub machine?

Thanks for the great work already!

mregni commented 1 year ago

Nevermind, I'm so stupid My sub machine IP is 192.168.72.225 instead of 192.168.72.255 (wrong config)

ldellisola commented 1 year ago

Haha that's fine. Enjoy your working config now!