[英]Traefik 2.1 does not forward request
我想使用 Traefik 作为后端的负载均衡器,它正在侦听端口2500
。 应该有两个后端容器来处理端口80
上的请求。 Traefik 仪表板应该在端口8080
上可用。 我还希望后端容器在崩溃时自动重新启动。
当我使用docker-compose --compatibility up --build
运行下面的docker-compose --compatibility up --build
docker-compose
文件docker-compose --compatibility up --build
,我可以访问 localhost 2500
和2501
上的两个后端。 但是,后端应该只能通过端口80
上的 Traefik 使用。 不幸的是,我无法访问端口80
上的后端。 谢谢你的帮助。
version: "3.4"
services:
backend:
deploy:
replicas: 2
build: .
ports:
- "2500-2501:2500"
restart: always
healthcheck:
test: curl http://127.0.0.1:2500 -s -f -o /dev/null || exit 1
interval: 10s
timeout: 10s
retries: 3
reverse-proxy:
image: traefik
command:
- --api.insecure=true
- --providers.docker=true
- --entrypoints.web.address=:80
ports:
- 80:80
- 8080:8080
volumes:
- /var/run/docker.sock:/var/run/docker.sock
暴露的端口从后端服务中删除。 添加了在 127.0.0.1:80 --> 127.0.0.1:2500 上工作的后端路由器。 还为 traefik 暴露了 2500 端口。
version: "3.4"
services:
backend:
deploy:
replicas: 2
build: .
#############################################################################
#ports:
# - "2500-2501:2500"
#############################################################################
labels:
traefik.enable: true
traefik.http.routers.backend.rule: Host(`127.0.0.1`)
traefik.http.routers.backend.entrypoints: web
traefik.http.services.backend_service.loadbalancer.server.port: 2500
#############################################################################
restart: always
healthcheck:
test: curl http://127.0.0.1:2500 -s -f -o /dev/null || exit 1
interval: 10s
timeout: 10s
retries: 3
reverse-proxy:
image: traefik
command:
- --api.insecure=true
- --providers.docker=true
- --entrypoints.web.address=:80
ports:
- 80:80
- 8080:8080
#############################################################################
- 2500:2500
#############################################################################
volumes:
- /var/run/docker.sock:/var/run/docker.sock
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.