Gateway timeout with traefik and php fpm
I think I may have had a similar issue to what you are/were experiencing. Take a look at this GitHub issue: https://github.com/containous/traefik/issues/979
If your problem is the same as mine, here is the issue:
Traefik is on a "front facing" network, so is one of your services, but that service is also part of a "back facing" network. Traefik, by default, doesn't know what network to send requests to... so it sends them to a randomly chosen one of the two IP address options (picked at the creation of that container). If Traefik isn't part of that network, it wont be able to reach that container, and will give you a Gateway Timeout.
Solution: add a label to your container to directly specify to Traefik what network it should be communicating on:
labels:
- "traefik.enable=true"
- "traefik.docker.network=<folder prefix>webgateway"
- "traefik.backend=<backend service"
- "traefik.frontend.rule=Host:<host setting>"
Pro tip: use docker network ls
to figure out what the actual name of your network is, because it is not what docker-compose says in the file. The actual network name is prefixed based on the name of the folder that it is run in. (I don't know why, and I don't like it, but that is the world we live in)
Hence the <folder prefix>
in my above example.
What I do is define in a file called .env
in the same dir as docker-compose.yml
a variable for the project name (that ends as the prefix for all containers/networks/etc). It should only contain characters, no spaces, dashes, etc.
COMPOSE_PROJECT_NAME=myproject
Then, in your application label, you use the variable name appended with the created network separated by "_":
- "traefik.docker.network=${COMPOSE_PROJECT_NAME}_mynetwork"