[英]Expose Traefik dashboard to subdomain
I've got a Traefix set up and I'm trying to expose a dashboard to a website served through Cloudflare with SSL.我已经设置了 Traefix,我正在尝试将仪表板暴露给通过 Cloudflare 和 SSL 提供服务的网站。 I've combed through the docs and I can't for the life of me figure out how to expose the docs to a subdomain of one of my sites.
我已经梳理了文档,但我一生都无法弄清楚如何将文档暴露给我的一个网站的子域。 I've got the following docker-compose file:
我有以下 docker-compose 文件:
services:
traefik:
container_name: traefik
image: "traefik"
labels:
- "traefik.enable=true"
- "traefik.http.routers.dashboard.rule=Host(`foo.bar.dev`) && PathPrefix(`/`)"
- "traefik.http.routers.dashboard.entrypoints=websecure"
- "traefik.http.routers.dashboard.service=dashboard@internal"
- "traefik.http.routers.dashboard.middlewares=dashboard_redirect@internal,dashboard_stripprefix@internal"
- "traefik.http.routers.dashboard.priority=2"
- "traefik.http.routers.api.rule=Host(`foo.bar.dev`) && PathPrefix(`/api`)"
- "traefik.http.routers.api.entrypoints=websecure"
- "traefik.http.routers.api.service=api@internal"
- "traefik.http.routers.api.priority=1"
- "traefik.http.routers.api.middlewares=dashboard_redirect@internal,dashboard_stripprefix@internal"
ports:
- "443:443"
- "8080:8080"
expose:
- 443
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
- "./traefik.toml:/traefik.toml"
version: "3.3"
and the following traefik.toml file:以及以下 traefik.toml 文件:
[accessLog]
[api]
dashboard = true
insecure = true
[providers.docker]
exposedByDefault = false
[entryPoints]
[entryPoints.websecure]
address = ":443"
I still get a 404 on the subdomain.我仍然在子域上得到 404。 The certificates are arranged by cloudflare so I land on port 443 in my network without any problems.
证书是由 cloudflare 安排的,所以我登陆我网络中的端口 443 没有任何问题。 My port is then forwarded by my routers to my Traefix server.
然后我的端口由我的路由器转发到我的 Traefix 服务器。 I feel like the host rule is not being triggered because when I access port 8080 directly from the IP in the internal network I can access the dashboard and see the two rules set in docker.
我觉得主机规则没有被触发,因为当我直接从内部网络中的 IP 访问端口 8080 时,我可以访问仪表板并查看 docker 中设置的两个规则。
Anybody who can point me in the right direction?谁能指出我正确的方向?
I eventually got it work with the following configuration:我最终使它与以下配置一起工作:
version: "3.3"
services:
traefik:
container_name: traefik
image: "traefik"
networks:
- webgateway
labels:
- "traefik.enable=true"
- "traefik.http.routers.dashboard.rule=Host(`foo.bar.dev`)"
- "traefik.http.routers.dashboard.entrypoints=websecure"
- "traefik.http.routers.dashboard.tls"
- "traefik.http.services.dashboard.loadbalancer.server.port=8080"
ports:
- "443:443"
expose:
- 8080
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
- "./traefik.toml:/traefik.toml"
networks:
webgateway:
driver: bridge
[log]
level = "DEBUG"
[accessLog]
[api]
dashboard = true
insecure = true
[providers.docker]
exposedByDefault = false
[entryPoints]
[entryPoints.websecure]
address = ":443"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.