我在 docker swarm 环境中部署 portainer 和 traefik。我可以使用 domain 访问 traefik 仪表板traefik.example.com
。我还想代理到 portainer 容器,但是当我点击时portainer.example.com
出现 404 错误。traefik 中的日志没有显示任何关于点击该网址的信息
proxy_traefik.0.f5zxe8dngv29@dvc2 | time="2020-05-22T13:45:40Z" level=debug msg="allLabelsmap[:map[traefik.frontend.rule:Host(`traefik.shmmir.ml`) traefik.port:8080]]"
proxy_traefik.0.f5zxe8dngv29@dvc2 | time="2020-05-22T13:45:40Z" level=debug msg="originLabelsmap[com.docker.stack.image:traefik:v1.7.16 com.docker.stack.namespace:proxy traefik.frontend.rule:Host(`traefik.shmmir.ml`) traefik.port:8080]"
proxy_traefik.0.f5zxe8dngv29@dvc2 | time="2020-05-22T13:45:40Z" level=debug msg="allLabelsmap[:map[traefik.frontend.rule:Host(`traefik.shmmir.ml`) traefik.port:8080]]"
proxy_traefik.0.f5zxe8dngv29@dvc2 | time="2020-05-22T13:45:40Z" level=debug msg="originLabelsmap[com.docker.stack.image:portainer/portainer com.docker.stack.namespace:portainer traefik.enable:true traefik.http.routers.portainer.entrypoints:http traefik.http.routers.portainer.rule:Host(`portainer.shmmir.ml`) traefik.http.routers.portainer.service:portainer traefik.http.services.portainer.loadbalancer.server.port:9000]"
proxy_traefik.0.f5zxe8dngv29@dvc2 | time="2020-05-22T13:45:40Z" level=debug msg="allLabelsmap[:map[traefik.enable:true traefik.http.routers.portainer.entrypoints:http traefik.http.routers.portainer.rule:Host(`portainer.shmmir.ml`) traefik.http.routers.portainer.service:portainer] http.services.portainer.loadbalancer.server:map[traefik.port:9000]]"
proxy_traefik.0.f5zxe8dngv29@dvc2 | time="2020-05-22T13:45:40Z" level=debug msg="Backend backend-portainer-web-http-services-portainer-loadbalancer-server: no load-balancer defined, fallback to 'wrr' method"
proxy_traefik.0.f5zxe8dngv29@dvc2 | time="2020-05-22T13:45:40Z" level=debug msg="Backend backend-proxy-traefik: no load-balancer defined, fallback to 'wrr' method"
proxy_traefik.0.f5zxe8dngv29@dvc2 | time="2020-05-22T13:45:40Z" level=debug msg="Configuration received from provider docker: {\"backends\":{\"backend-portainer-web-http-services-portainer-loadbalancer-server\":{\"servers\":{\"server-portainer-web-1-d30efeb58bae18c84b91c7662dd19a7a\":{\"url\":\"http://10.0.98.159:9000\",\"weight\":1}},\"loadBalancer\":{\"method\":\"wrr\"}},\"backend-proxy-traefik\":{\"servers\":{\"server-proxy-traefik-f5zxe8dngv29a259b42l1tu78-e19913f7535b25062e55b9f66b4c375b\":{\"url\":\"http://10.0.98.4:8080\",\"weight\":1},\"server-proxy-traefik-rm54k6hi3dbmzfl7udi83xhej-cb81f0e3dbaa25243ab90850c80dc1a5\":{\"url\":\"http://10.0.98.3:8080\",\"weight\":1}},\"loadBalancer\":{\"method\":\"wrr\"}}},\"frontends\":{\"frontend-Host-traefik-shmmir-ml-0\":{\"entryPoints\":[\"http\",\"https\"],\"backend\":\"backend-proxy-traefik\",\"routes\":{\"route-frontend-Host-traefik-shmmir-ml-0\":{\"rule\":\"Host(`traefik.shmmir.ml`)\"}},\"passHostHeader\":true,\"priority\":0,\"basicAuth\":null},\"frontend-http-services-portainer-loadbalancer-server-portainer-web-http-services-portainer-loadbalancer-server\":{\"entryPoints\":[\"http\",\"https\"],\"backend\":\"backend-portainer-web-http-services-portainer-loadbalancer-server\",\"routes\":{\"route-frontend-http-services-portainer-loadbalancer-server-portainer-web-http-services-portainer-loadbalancer-server\":{\"rule\":\"Host:portainer-web.traefik\"}},\"passHostHeader\":true,\"priority\":0,\"basicAuth\":null}}}"
proxy_traefik.0.f5zxe8dngv29@dvc2 | time="2020-05-22T13:45:40Z" level=info msg="Skipping same configuration for provider docker"
但是当我使用端口号 9000 公开 portainer 并点击时,example.com:9000
我可以得到它的 UI。所以这意味着也许我的规则不起作用或什么的。这是我在搬运工服务中使用的标签
labels:
- 'traefik.enable=true'
- 'traefik.http.routers.portainer.entrypoints=http'
- 'traefik.http.routers.portainer.rule=Host(`portainer.${DOMAIN}`)'
# - 'traefik.http.routers.portainer_.entryPoints=websecure'
- 'traefik.http.routers.portainer.service=portainer'
- 'traefik.http.services.portainer.loadbalancer.server.port=9000'
和 traefik 服务的标签
labels:
- traefik.enable=true
- traefik.port=8080
- traefik.frontend.rule=Host(`traefik.${DOMAIN}`) #traefik.${DOMAIN}
我把它们放在同一个网络上,
traefik service
networks:
- proxy
- traefik-consul
- traefik-docker
portainer service
networks:
- proxy
- portainer
PS:Traefik 使用的是这张图片image: traefik:v1.7.16
我真的不明白。。