Traefik 中是否有等效于 Apache 的 ReverseProxyPass? [英] Is there an equivalent to ReverseProxyPass for Apache in Traefik?
问题描述
我已将 Traefik 设置为在 Docker Swarm 模式下工作.我已使用以下命令将 Portainer 部署到集群中:
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
可以看出,我已经配置了 Traefik,通过使用标签,将 /portainer
的请求代理到 Portainer 服务.然而,Protainer 提供的链接来自 /
,因为它不知道它正在被代理,因此应用程序不起作用,因为 Traefik 不知道如何路由每个链接.
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.
我试图避免更改服务的部署以与 Traefik 一起使用,因为我希望它是透明的.为此,是否可以让 Traefik 像 ReverseProxyPass
for Apache 那样重写来自服务的链接?
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?
我知道 Traefik 现在设置了 X-Forwarded-Prefix
但我不知道如何让 Portainer 之类的东西开箱即用,或者实际上是从 Docker 安装的其他服务以商店为例.
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.
所以现在我打电话:
http://dummy.localhost/portiner/
这篇关于Traefik 中是否有等效于 Apache 的 ReverseProxyPass?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!