Hi everyone,
I am trying to setup a traefik container that redirects all request to localhost:80
automatically to the good container like this :
What did I expect to see?
- When I go to
localhost/<container-name>/hello
- Redirect to the container named , so
<container-name>/hello
What did I see instead?
- When I go to
localhost/<container-name>/hello
- I am redirected to the
<container-name>/<container-name>/hello
The problem is that the path /<container-name>/hello
is keeped so I want to remove /<container-name>
My traefik configuration
## traefik.yml
accessLog: {}
# Docker configuration backend
providers:
docker:
defaultRule: "PathPrefix(`/{{ .Name }}`)"
# API and dashboard configuration
api:
debug: true
insecure: true
Someone have an idea, how to do that ?
Hi @bruno-motacardoso, you need to enable (and configure) a middleware named "Strip Prefix" for each router. You can find here the documentation of the middleware:https://docs.traefik.io/v2.0/middlewares/stripprefix/, and here an example of this use case: https://docs.traefik.io/v2.0/migration/v1-to-v2/#strip-and-rewrite-path-prefixes .
Hi @dduportal , thanks for your answer. Can I configure this middleware for each router automatically?
Does it exist a defaultMiddleware
in docker provider like defaultRule
?
Like this, the traefik configuration be completely independent to docker containers.
Hi @bruno-motacardoso , it is not possible as far as I know, since the goal of Traefik is to get its configuration from the backends metadatas (container's labels, Kubernetes manifests, etc.).
Only the defaultRule
can be defined in this case.
Ok thanks for your clear answer
1 Like