Is there an equivalent to ReverseProxyPass for Apache in Traefik?

倾然丶 夕夏残阳落幕 提交于 2019-12-19 09:02:46

问题


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.


回答1:


My mistake, this is working. I was omitting the trailing / from the request. When I add this, it all works.

So now I call:

http://dummy.localhost/portainer/



来源:https://stackoverflow.com/questions/44246098/is-there-an-equivalent-to-reverseproxypass-for-apache-in-traefik

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!