Docker Community Forums

Share and learn in the Docker community.

Nginx, PHP-FPM, Traefik - Bad Gateway (504)

Greetings together,

an while ago i’ve setup a docker-stack for an webserver. this included nginx, php-fpm and traefik. Everything worked well until in needed to do an clean install on my server.

I moved my docker-stacks-folder to the new system and can’t get the webserver services back up working.
The first problem was, that traefik hat a problem and didnt worked, so i needed to add a dummy label into any service for traefik to make it work.
labels: ....

Well, i still dunno why, but it seems to make traefik work. SHould that really be an valid solution?
Anyway. When i try to access one of my services, no matter if i make use of ip or domain, iam getting an 502 or 504 error. This happens on all my services that are located in nginx.

Weirdly, if i create an phpinfo, that seems to work. I googled much arround and tryed solutions like, increasing timeouts, childrens etc, but nothing worked.

Now iam here and hope someone could help me please, to find the problem.


  • Debian 10.5
  • Docker version 19.03.13, build 4484c46d9d
  • php:7.4.11-fpm
  • nginx:1.19.3
  • traefik:v2.3.2



If anything else is needed, please let me know.

Thx in advance.

If “a while ago” is a little bit longer then you probably have a config for Traefik 1. Try with traefik:v1.7.

No, i havn’t. It was already Traefik2. See below… That also didn’t worked. :frowning:

Old Versions on initial working setup. arround 1 year ago.

  • traefik:v2.2.1
  • nginx:1.18.0
  • php-7.4.6
  • mariadb:10.5.3

Does anybody have an idea, what can cause the problem and how to solve?


Sorry, I should have seen that this is a traefik 2 config.

For what reason do you configure all these networks, MAC and IP addresses?

ive done an macvlan, so some containers have an ip of my phisical network. with the static mac iam able to forward the port to the container from my router, and make a service accesible via internet.
i wanted to use different internal IPs per container.

It is a wrong approach to assign IP addresses to containers, containers are no virtual machines. If you have a traefik container that manages the connection to the outside you can publish this one to the host. The connections between nginx, php and mariadb can be done inside Docker and there is no need for a manual configuration.

iam running docker on an openmediavault. so iam not able to expose port 80 and 443 for traefik on the same ip, cause this would end up ppl reaching my openmediavault gui from web. thats why i’ve done this in past.
It also worked but currently it won’t anymore, and i still dont know why. my Other containers (like teamspeak, gittea etc) still working and using the same networking method. it just affects this nxginx / php-fpm containers.

and if i need to communitcate between containers, i use the docker internal ips ofc.

edit1: I changed the ovm port now. iam using only docker internal for communicate and expose 80+443 on ovm host ip. But the issue persists. :frowning:

Well, i recreated the full docker-compose based on 3.7 now. I still dont know what i did different but it works now. thanks much.

Thank you slot my friend :DD