I have a docker Container for Traefik with network traefik, and three Containers in different Networks with use Traefik.
Nginx does not have a specific server_name (server_name _;), as I thought traefik redirects the data correctly according to the service name. Each nginx has its own network because there are several related containers (PHP, DB,...) in separate docker-compose.yml files.
I have defined specific name for each nginx, but traefik switch between them. I call domain1.test, and sometimes i get the content of domain2 or domain3.
What have I forgotten to configure to make it work?
Shorted docker compose:
traefik:
image: traefik:3.0
container_name: traefi
ports:
- "80:80"
- "443:443"
networks:
net_traefik:
nginx-containetr1:
build:
......
container_name: nginx-container1
labels:
- "traefik.enable=true"
- "traefik.http.routers.container1.rule=Host(`container1.test`) || Host(`www.container1.test`)"
- "traefik.http.routers.container1.entrypoints=webSecure"
- "traefik.http.routers.container1.tls=true"
.....
- "traefik.http.routers.container1.service=container1"
- "traefik.http.services.container1.loadbalancer.server.port=80"
- "traefik.docker.network=traefik"
networks:
- traefik
- container1
nginx-containetr1:
build:
......
container_name: nginx-container2
labels:
- "traefik.enable=true"
- "traefik.http.routers.container2.rule=Host(`container2.test`) || Host(`www.container2.test`)"
- "traefik.http.routers.container2.entrypoints=webSecure"
- "traefik.http.routers.container2.tls=true"
.....
- "traefik.http.routers.container2.service=container2"
- "traefik.http.services.container2.loadbalancer.server.port=80"
- "traefik.docker.network=traefik"
networks:
- traefik
- container2