TransWikia.com

Traefik 2 Gateway Timeout

Stack Overflow Asked by Casey Daniel on December 25, 2021

So I have the following docker-compose.yml

version: "3.7"

services:
    roundclinic-mysql:
        image: mysql:5.7
        networks:
            - spring-boot-mysql-network
        environment:
            - MYSQL_DATABASE=
            - MYSQL_USER=
            - MYSQL_PASSWORD=
            - MYSQL_ROOT_PASSWORD=
        volumes:
            - ./mysqldata:/var/lib/mysql:rw,delegated
        ports:
            - "3306:3306"
    web-service:
        image: roundclinic/roundclinic:latest
        networks:
            - spring-boot-mysql-network
            - traefik-network
        depends_on:
            - roundclinic-mysql
        ports:
            - 8080:8080
        environment:
            - "SPRING_PROFILES_ACTIVE=dev"
        links:
            - roundclinic-mysql
        labels:
            - "--providers.docker.network=traefik_default"
            - "traefik.enable=true"
            - "traefik.http.routers.roundclinic.rule=Host(`api-dev.roundclinic.app`)"
            - "traefik.http.routers.roundclinic.entrypoints=web"
            - "traefik.http.services.cal.loadbalancer.server.port=8080"
    traefik:
        image: "traefik:v2.2"
        container_name: "traefik"
        command:
            - "--log.level=DEBUG"
            - "--api.insecure=true"
            - "--providers.docker=true"
            - "--providers.docker.exposedbydefault=false"
            - "--entrypoints.web.address=:80"
            - "traefik.docker.network=traefik-network"
        ports:
            - "80:80"
        volumes:
            - "/var/run/docker.sock:/var/run/docker.sock:ro"
networks:
    traefik-network:
        driver: bridge
        external: true
    spring-boot-mysql-network:
        driver: bridge
volumes:
    my-db: 

Spring boot starts up fine and can connect to mysql.

When I connect to http://api-dev.roundclinic.app:8080/../ I can hit my application just fine

When I connect to http://api-dev.roundclinic.app/../ I get a gateway timeout. I can see in the traefik logs that it’s forwarding the request to what seems to be the correct IP and port, but nothing hits the actual application. I’m not sure what’s going on here. Any help?

One Answer

When accessing port 8080 you are bypassing Traefik and directly access your application, correct?

Generally speaking the Traefik labels look good. Entrypoint, Port and Host are defined, router and service port are present. These are usually all the requirements for Docker-based setups.

One thing that I noticed is that the traefik container uses "traefik.docker.network=traefik-network", but your web app uses: "--providers.docker.network=traefik_default".

I am not sure if traefik_default is something that traefik provides but that mismatch in network names might be the issue.

I can't test if that is the problem but that would be the first thing to check. One way would be to simplify your config but just always using the networks key from docker compose instead of mixing it with labels and arguments.

Answered by scepticulous on December 25, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP