使 Traefik 路由到同一台机器上不同端口的服务
make Traefik route to a service on the same machine at a different port
我在端口 5678
的节点上有一个服务 (myapp
) 运行。我在同一个节点上 运行 Traefik(例如 myip
)。我如何让 Traefik 将任何对 http://myip/myapp
的请求路由到端口 5678
的 myapp
服务 运行?
在 Traefik 中 2.x 你可以在中间件中使用 redirectRegex:
middlewares:
cleanerRegex:
redirectRegex: # <== this is it!
regex: "^http?://example.com/myapp"
replacement: "https://example.com:5678/"
[...]
我在端口 5678
的节点上有一个服务 (myapp
) 运行。我在同一个节点上 运行 Traefik(例如 myip
)。我如何让 Traefik 将任何对 http://myip/myapp
的请求路由到端口 5678
的 myapp
服务 运行?
在 Traefik 中 2.x 你可以在中间件中使用 redirectRegex:
middlewares:
cleanerRegex:
redirectRegex: # <== this is it!
regex: "^http?://example.com/myapp"
replacement: "https://example.com:5678/"
[...]