我有三个子域api.mydomain.com
,dl.mydomain.com
和blog.mydomain.com
,我有一个容器有3个端口(5000,5001,5002)......
现在我想将api.mydomain.com
绑定到端口5000,将dl.mydomain.com
绑定到端口5001,将blog.mydomain.com
绑定到端口5002。
注意:我使用docker-compose进行一对一绑定我使用blowe代码
my_container:
container_name: my_container
restart: always
build: .
labels:
- "traefik.backend=my_container"
- "traefik.enable=true"
- "traefik.docker.network=web"
- "traefik.frontend.rule=Host:api.mydomain.com"
您应该能够通过细分来实现这一目标:https://docs.traefik.io/configuration/backends/docker/#on-containers-with-multiple-ports-segment-labels
traefik.<segment_name>.frontend.rule=EXP
traefik.<segment_name>.port=PORT
[...]