It seems that traefik automatically detects the port based on the EXPOSE settings in the docker image. I have set EXPOSE 3000 in my dockerfile and it automatically creates a service and routes it correctly to the internal ip on port 3000.
I also tried what you proposed, but the request URL is still invalid.
You don't have to strip the prefix /dashboard, as all your request to http://domain.com/dashboard will be routed to http://container_ip/
Maybe try something like this :
dashboard:
image: myproject/dashboard:latest
container_name: dashboard
ports:
- "3000:3000" # To see that the container is running fine
labels:
- "traefik.enable=true"
- "traefik.docker.network=mynetwork"
- "traefik.http.routers.dashboard.entrypoints=http"
- "traefik.http.routers.dashboard.rule=PathPrefix(`/dashboard`)"
- "traefik.http.services.dashboard.loadbalancer.server.port=3000"
You don't have to strip the prefix /dashboard, as all your request to http://domain.com/dashboard will be routed to http://container_ip/
Cool, I was not aware of that! Thought the path also was sent to the container. I want the dashboard to be available on http://domain.com/dashboard and not on root.
This is my traefik.toml file.
[log]
level = "DEBUG"
# Entrypoints to be used by frontends that do not specify any entrypoint.
# Each frontend can specify its own entrypoints.
#defaultEntryPoints = ["http", "https"]
[entryPoints]
[entryPoints.http]
address = ":80"
[entryPoints.http.forwardedHeaders]
insecure = true
[entryPoints.https]
address = ":443"
[api]
insecure = true
# Enable Docker configuration backend
[providers]
[providers.file]
directory = "/etc/traefik"
filename = "dynamic_conf.toml"
watch = true
debugLogGeneratedTemplate = true
[providers.docker]
endpoint = "unix:///var/run/docker.sock"
watch = true
exposedByDefault = false
I had to add the rule with loadbalancer service and also create a vue.config.js file (at the same level as the package.json file) with the following content: