Traefik + docker: Unable to route based on host name

My goal

My docker-compose.yml

version: "3.9"
services:

  nginx:
    image: nginx
    container_name: nginx
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.nginx.rule=Host(`nginx.test`)"
      - "traefik.http.services.nginx.loadbalancer.server.port=80"
    ports:
      - "9000:80"
    expose:
      - 80

  apache:
    image: httpd
    container_name: apache
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.apache.rule=Host(`apache.test`)"
      - "traefik.http.services.apache.loadbalancer.server.port=80"
    expose:
      - 80
    ports:
      - "9001:80"

  proxy:
    image: "traefik:v2.5"
    container_name: "proxy"
    command:
      - "--log.level=DEBUG"
      - "--api.insecure=true"
      - "--providers.docker=true"
      - "--entrypoints.web.address=:80"

    depends_on:
      - nginx
      - apache
    ports:
      - "80:80"
      - "8080:8080"
    volumes:
      - ./proxy.sock:/var/run/proxy.sock:ro

Actually I can see that both apache and nginx are running , because I can access using

But I cannot access without using port numbers

Inspecting traefik container I noticed

2024-03-07 10:56:16 time="2024-03-07T09:56:16Z" level=debug msg="FIXME: Got an status-code for which error does not match any expected type!!!: -1" status_code=-1 module=api
2024-03-07 10:56:16 time="2024-03-07T09:56:16Z" level=error msg="Failed to retrieve information of the docker client and server host: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?" providerName=docker
2024-03-07 10:56:16 time="2024-03-07T09:56:16Z" level=error msg="Provider connection error Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?, retrying in 27.440293063s" providerName=docker

Compare with simple Traefik example.

Your docker socket mount seems wrong.

Use a common Docker network.

Why do you use an over 2 years old Traefik version?

1 Like

Ohhhh. thanks ... it was the only part I copy/pasted without understanding its goal.

Now all works very, very, very, well.

The integration with docker-compose is so easy I must not write a single config in external files.
WOW !!!

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