基于url路径的Docker服务重定向
我正在使用docker swarm并部署3个tomcat服务,每个服务在容器内的8443和主机容器上的844484458446上运行 我希望使用8443上运行的代理服务器,它将根据url路径将传入的请求重定向到相应的服务基于url路径的Docker服务重定向,docker,nginx,docker-swarm,traefik,Docker,Nginx,Docker Swarm,Traefik,我正在使用docker swarm并部署3个tomcat服务,每个服务在容器内的8443和主机容器上的844484458446上运行 我希望使用8443上运行的代理服务器,它将根据url路径将传入的请求重定向到相应的服务 https://hostname:8443/a – > https://hostname:8444/a https://hostname:8443/b – > https://hostname:8445/b https://hostname:8443/c – >
https://hostname:8443/a – > https://hostname:8444/a
https://hostname:8443/b – > https://hostname:8445/b
https://hostname:8443/c – > https://hostname:8446/c
我的示例Docker编写文件
version: "3"
services:
tomcat1 :
image: tomcat:1
ports:
- "8446:8443"
tomcat2 :
image: tomcat:1
ports:
- "8444:8443"
tomcat3 :
image: tomcat:1
ports:
- "8445:8443"
我已经探索过Traefik和nginx,但无法找到基于url的重新路由。任何建议。您可以使用带有标签Host和Path的基于规则的traefik 差不多
version: "3"
services:
traefik:
image: traefik
command: --web --docker --docker.swarmmode --docker.watch --docker.domain=hostname
ports:
- "80:80"
- "8080:8080"
- "443:443"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
deploy:
placement:
constraints: [node.role == manager]
restart_policy:
condition: on-failure
tomcat1:
image: tomcat:1
labels:
- traefik.backend=tomcat1
- traefik.frontend.rule=Host:hostname;PathPrefixStrip:/a
- traefik.port=8443