我要使用traefik2.0发布端口80和7000,端口7000用于frp(TCP)。现在,我正在使用2.0 doc在本地进行测试,我在快速入门中使用示例,但未运行。
这是我的docker compose文件。
version: '3'
services:
reverse-proxy:
image: traefik:v2.0 # The official v2.0 Traefik docker image
command:
- "--api"
- "--entrypoints='Name:http Address::80'"
- "--providers.docker" # Enables the web UI and tells Traefik to listen to docker
- "--providers.docker.swarmmode=true"
- "--providers.docker.watch=true"
ports:
- "80:80" # The HTTP port
- "8080:8080" # The Web UI (enabled by --api)
networks:
- traefik-net
deploy:
replicas: 1
placement:
constraints:
- node.role == manager
labels:
- traefik.enable=false
volumes:
- /var/run/docker.sock:/var/run/docker.sock # So that Traefik can listen to the Docker events
whoami:
image: containous/whoami # A container that exposes an API to show its IP address
networks:
- traefik-net
deploy:
labels:
- "traefik.http.routers.whoami.tls=true"
- "traefik.http.routers.whoami.entrypoints=https"
- "traefik.http.routers.whoami.rule=Host(`whoami.domain.com`)"
- "traefik.http.middlewares.whoami.redirectscheme.scheme=https"
networks:
traefik-net:
external: true
我希望traefik2.0上使用的标签可以工作
答案 0 :(得分:1)
您快到了!
替换
- "--entrypoints='Name:http Address::80'"
使用
- "--entryPoints.web.address=:80"
- "--entrypoints.websecure.address=:443"
在非生产环境中启用仪表板。您还需要替换
- "--api"
与
- "--api.insecure=true"
whoami的标签之一有误。没有https入口点,现在称为websecure。所以改变
- "traefik.http.routers.whoami.entrypoints=https"
使用
- "traefik.http.routers.whoami.entrypoints=websecure"
最后公开运行whoami应用程序的内部端口。
通过将其添加到whoami的标签中
- traefik.http.services.whoami-service.loadbalancer.server.port=80
您应该能够使用localhost:8080上的traefik仪表板对其进行验证