Proxying an App with Multiple Exposed Ports
By default, Traefik picks up exposed ports for every app using the default dockerfile. If for some reason the developer did not add this port to the dockerfile or multiple ports are exposed, we may have to tell Traefik which port to use for the web UI.
If you are using docker-compose then you simply need to add a single line to the compose files under labels:
WARNING
You must replace app
with the name of your application that this label is being added to otherwise Traefik will see duplicates.
To show you a full example, we will add the label to an existing docker-compose.yml file for Adminer.
Now while in the same directory as the docker-compose.yml
file, run the command docker-compose up -d
and it should recreate the container for you with the latest labels. Now when you deploy your application you will be able to visit it by going to your domain with the app name as the subdomain (APP-NAME.DOMAIN.COM
).
PLEASE NOTE
You can add multiple of these labels at once before finally deploying your application.
Conclusion
Traefik will now use the port specified to forward all traffic to the app correctly.
Last updated