I have setup Traefik to work in Docker Swarm mode. I have deployed Portainer into the cluster with the following command:
docker service create \
\
--label "traefik.port=9000" \
--label "traefik.docker.network =traefik-net" \
--label "traefik.frontend.rule=Host:`hostname -f`;PathPrefixStrip:/portainer" \
--label="traefik.backend=portainer" \
\
--network traefik-net \
--constraint "node.role == manager" \
-p 9000:9000 \
--mount "type=bind,src=/var/run/docker.sock,dst=/var/run/docker.sock" \
--name portainer \
portainer/portainer
As can be seen I have configured Traefik, through the use of labels, to proxy the request for /portainer
to the Portainer service. However the links that are served by Protainer are from /
as it does not know it is being proxied, so the application does not work as Traefik does not know how to route each link.
I am trying to avoid having to change the deployments of services to work with Traefik as I want it to be transparent. To that end is it possible to get Traefik to rewrite the links from the service like ReverseProxyPass
for Apache does?
I know that Traefik now sets the X-Forwarded-Prefix
but I am not sure how to get things like Portainer to use it out of the box or indeed other services that are installed from the Docker Store for example.
My mistake, this is working. I was omitting the trailing /
from the request. When I add this, it all works.
So now I call:
来源:https://stackoverflow.com/questions/44246098/is-there-an-equivalent-to-reverseproxypass-for-apache-in-traefik