Hi at all,
I have been running some websites for the last two years with an nginx webserver and traefik as reverse proxy in a docker-compose stack (as described in this guide). The Traefik configuration takes place as a dynamic CLI, in the same Docker Compose file.
Now I had to change my server setup and the docker container of nginx webserver runs in a different docker stack (different server) than traefik. However, it can be reached in the LAN via a fixed IP.
I would like to create a yaml file for the dynamic Traefik configuration that forwards the incoming requests to the IP of the nginx web server. The structure of the yaml file looks like this:
Unfortunately, till now I'm not able to open the website and I always get a 404 error message.
Can someone help me by solving this issue? Do I need to make changes in the nginx conf files?
Hi, thanks for the advices. The dynamic config file is loaded correctly. I mounted a "rules" folder, which contains several other config files, that all work well. In traefik logs (debug mode) I have no entrys, related to this issue. Docker Swarm is actually no alternative solution for my setup. - So maybe there are other ideas, how to solve the problem. - Thanks for your help in advance.
Hi, and thanks again for the advices. I was able to solve the issue.
One part of the problem was related to the environment variable DOMAINNAME, which cannot be named $DOMAINNAME in the dynamic Traefik configuration file, otherwise it will not be recognized. Instead, the variable must be addressed as follows: {{env "DOMAINNAME"}}
I'm not sure if this is the only way, but that's definitely how it works and traefik uses the correct domain.
The entire affected line of code then looks like this:
rule: "Host(`website.{{env "DOMAINNAME"}}`)"
My second mistake was, that I had to explicitly expose the port in the nginx docker container, through which the container should be accessible:
ports:
- 80:80
In the previous CLI traefik configuration, which were running in the same Docker stack, this was understandably not necessary.