【发布时间】:2020-01-08 12:50:49
【问题描述】:
我想通过 traefik 将一个 URL 重定向到另一个 URL。
我正在使用 docker 进行此配置,下面是我的 docker-compose.yml 文件
version: '3'
services:
reverse-proxy:
# The official v2.0 Traefik docker image
image: containous/whoami
container_name: "whoami_cont"
# Enables the web UI and tells Traefik to listen to docker
ports:
# The HTTP port
- 80:80
# The Web UI (enabled by --api.insecure=true)
- 8080:8080
labels:
- traefik.http.middlewares.test-replacepathregex.replacepathregex.regex=^(https?|ftp|file)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]
- traefik.http.middlewares.test-replacepathregex.replacepathregex.replacement=http://localhost:8081/4
然后我正在成功运行 docker-compose 命令。然后我将点击任何匹配正则表达式模式的 URL,但 URL 没有重定向到另一个 URL - http://localhost:8081/4 根据配置。 我正在使用 traefik 2.0 版
如果缺少任何配置,请告诉我。
【问题讨论】:
-
containous/whoami并不是真正的 Traefik docker 镜像,它只是一个用于测试的简单服务器。 -
那我应该使用哪张图片呢?我已经尝试过 traefik:v2.1.0 图像,但它不起作用。
标签: docker docker-compose traefik