traefik gateway timeout

This is a networking problem. The traefik container cannot reach the destination container.

This is most likely the problem of the default or specific network defined for traefik and the destination container. Assume this compose file:

services:
  app:
    image: someImage
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.myService.rule=Host(`myService.localhost`)"
      - "traefik.http.services.myService.loadbalancer.server.port=80"
    networks:
      - reverse_proxy

  reverse-proxy:
    image: traefik:latest
    build:
      context: docker/traefik
    ports:
      # The HTTP port
      - "80:80"
      # The HTTPS port
      - "443:443"
      # The Web UI (enabled by --api.insecure=true)
      - "8080:8080"
    volumes:
      # So that Traefik can listen to the Docker events
      - /var/run/docker.sock:/var/run/docker.sock
    networks:
      - reverse_proxy

So you’d think your traefik default network configuration would look like this:

[providers.docker]
  exposedByDefault = false
  network = "reverse_proxy"

But you have to remember that Docker will create the ACTUAL network with the name of the folder in which you’re running (in case of docker-compose) or the stack name (in case of Docker swarm stack):

[providers.docker]
  exposedByDefault = false
  network = "myServiceFolderName_reverse_proxy"

To check the existing networks start your Docker composition or deploy your stack and check the existing networks:

docker network ls
NETWORK ID     NAME                                  DRIVER    SCOPE
...
local
225ad63758e1   game_reverse_proxy                    bridge
...

(In this case the application is deployed via docker-compose and the “docker-compose up” command was fired inside a folder called “game”).