From time to time I had the issue that Traefik for some Docker containers returned Gateway Timeout
instead of the website under the configured URL. Accessing the page via an exposed port easily showed that the container was working fine. And I observed that it only happend for Stacks with multiple services running.
I introduced some time before these issues appeared new docker networks for my containers.
networks:
- revproxy
- xyz-internal
So, I added to all services that needed to be accessed by the Traeifk reverse-proxy the revproxy
network and for the internal communication between the other services the xyz-internal
network, with xyz
depending on the stacks name.
This lead to the case that Traefik selected one of the networks for communication as it didn't know which one was the correct one. So it worked by chance...
I found the solution after some googeling. (Unfurtunately, I lost the original site where it was mentioned during my search.) But here is the link to the Traefik documentation for it: traefik.docker.network
With the following line you can tell Traefik which docker network to use for message routing and I had no issues with Gateway Timeout
anymore.
label:
- traefik.docker.network: revproxy
You have to add the label on the service that needs to be accessed by Traefik and who hast the multiple networks configuered.
On some internet sites it is recomended to set the services network to host
. This will solve the issue as it removes the multiple networks from the config, but it introduces additional security issues, as now all ports of the container are exposed to the host and its connected networks. This is not a solution!