traefik - URL 的简单修改
traefik - simple modification of URL
我想修改我的 URL 的端点,同时它从 traefik 到我的一个容器。我要的是这个
我的 URL 看起来像这样 - http://backend/asd and it should point to one of my containers with different endpoint like this - http://asd/dfg
我试过的 -
asd:
image: asd
container_name: "asd"
labels:
- "traefik.backend=asd"
- "traefik.frontend.rule=Host:backend;PathPrefixStrip:/asd,PathPrefix:/dfg"
- "traefik.frontend.entryPoints=http"
- "traefik.enable=true"
- "traefik.port=80"
但这没有用。欢迎提出任何建议。
此致,
阿舒托什
您是否像这样在 docker-compose 中包含 Traefik-docker-图像?
traefik:
image: traefik
ports:
- 8080:80
volumes:
- /var/run/docker.sock:/var/run/docker.sock
command:
- "--docker"
对于您的路径替换“/asd”->“/dfg”,Traefik 的 ReplacePath-modifier 应该可以解决问题。以下 docker-label 是唯一的,您将需要:
labels:
- "traefik.frontend.rule=Path: /asd; ReplacePath: /dfg"
有了这个设置,做
curl http://localhost:8080/asd
应该return 来自路径“/dfg”上的“asd”容器的 HTTP 响应
我想修改我的 URL 的端点,同时它从 traefik 到我的一个容器。我要的是这个
我的 URL 看起来像这样 - http://backend/asd and it should point to one of my containers with different endpoint like this - http://asd/dfg
我试过的 -
asd:
image: asd
container_name: "asd"
labels:
- "traefik.backend=asd"
- "traefik.frontend.rule=Host:backend;PathPrefixStrip:/asd,PathPrefix:/dfg"
- "traefik.frontend.entryPoints=http"
- "traefik.enable=true"
- "traefik.port=80"
但这没有用。欢迎提出任何建议。
此致,
阿舒托什
您是否像这样在 docker-compose 中包含 Traefik-docker-图像?
traefik:
image: traefik
ports:
- 8080:80
volumes:
- /var/run/docker.sock:/var/run/docker.sock
command:
- "--docker"
对于您的路径替换“/asd”->“/dfg”,Traefik 的 ReplacePath-modifier 应该可以解决问题。以下 docker-label 是唯一的,您将需要:
labels:
- "traefik.frontend.rule=Path: /asd; ReplacePath: /dfg"
有了这个设置,做
curl http://localhost:8080/asd
应该return 来自路径“/dfg”上的“asd”容器的 HTTP 响应