traefik - URL 的简单修改 [英] traefik - simple modification of URL
问题描述
我想修改我的 URL 的端点,同时它从 traefik 到我的容器之一.我要的是这个.
我的 URL 看起来像这样 - http://backend/asd 并且它应该指向我的一个具有不同端点的容器,例如这 - http://asd/dfg
我试过的 -
I want to modify the endpoints of my URL, while it goes from traefik to one of my containers. What I want is this.
My URL looks like this - http://backend/asd and it should point to one of my containers with different endpoint like this - http://asd/dfg
What I tried -
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"
但这没有用.欢迎提出任何建议.
问候,
阿舒托什
But this didn't work. Any suggestions are welcome.
Regards,
Ashutosh
推荐答案
您是否包含 Traefik-docker-docker-compose 中的图像,像这样吗?
Are you including a Traefik-docker-image in your docker-compose, like so?
traefik:
image: traefik
ports:
- 8080:80
volumes:
- /var/run/docker.sock:/var/run/docker.sock
command:
- "--docker"
对于你的路径替换 "/asd" -> "/dfg",Traefik 的 ReplacePath-modifier 应该可以解决问题.以下 docker-label 是唯一的,您将需要:
For your path-replacement "/asd" -> "/dfg", Traefik's ReplacePath-modifier should do the trick. This following docker-label is the only, you will need:
labels:
- "traefik.frontend.rule=Path: /asd; ReplacePath: /dfg"
有了这个设置,做
curl http://localhost:8080/asd
应该从路径/dfg"上的asd"容器返回HTTP响应
should return the HTTP-response from your "asd"-container on path "/dfg"
这篇关于traefik - URL 的简单修改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!