如何从 URL 重定向到仪表板?
How to redirect to the dashboard from a URL?
我目前通过 http://traefik.my.server:8080/dashboard/
访问 V2 仪表板(Traefik 在 docker 容器中运行,8080 暴露给主机)。
我想更改它,以便仪表板在 http://traefik.my.server/dashboard
可用
我尝试添加以下标签来配置此行为,但在访问 http://traefik.my.server/dashboard
时出现 404
- traefik.http.routers.dashboard.rule=Host(`traefik.my.server:`) && Path(`/dashboard`)
- traefik.http.services.dashboard.loadbalancer.server.port=8080
- traefik.http.routers.dashboard.entryPoints=http
(http
入口点是端口 80
)
设置这种重定向的正确方法是什么
推荐阅读:
- https://docs.traefik.io/v2.1/operations/dashboard/#secure-mode
- https://blog.containo.us/traefik-2-0-docker-101-fc2893944b9d
- https://github.com/containous/blog-posts/tree/master/2019_09_10-101_docker
仅供参考,这不是重定向,而是路由。
https://community.containo.us/t/how-to-redirect-to-the-dashboard-from-a-url/4082/2
跟进@Idez 在 https://community.containo.us/t/how-to-redirect-to-the-dashboard-from-a-url/4082 的帮助,一个有效的配置是
docker-compose
文件:
services:
traefik:
container_name: traefik
image: traefik
ports:
- 80:80
- 443:443
restart: unless-stopped
volumes:
- /etc/docker/container-data/traefik:/etc/traefik
- /var/run/docker.sock:/var/run/docker.sock
- /etc/localtime:/etc/localtime:ro
labels:
- traefik.http.routers.api.rule=Host(`traefik.mydomain.org`)
- traefik.http.routers.api.service=api@internal
- traefik.http.routers.api.middlewares=lan
- traefik.http.middlewares.lan.ipwhitelist.sourcerange=192.168.10.0/24, 192.168.20.0/24
- traefik.enable=true
version: "3"
配置文件
global:
sendAnonymousUsage: true
entryPoints:
http:
address: ":80"
https:
address: ":443"
api:
dashboard: true
providers:
docker:
endpoint: "unix:///var/run/docker.sock"
exposedByDefault: false
defaultRule: "Host(`{{ index .Labels \"com.docker.compose.service\" }}.mydomain.org`)"
log:
level: INFO
#level: DEBUG
certificatesResolvers:
le:
acme:
email: le@mydomain.org
storage: /etc/traefik/acme.json
tlsChallenge: {}
#caServer: "https://acme-staging-v02.api.letsencrypt.org/directory"
我目前通过 http://traefik.my.server:8080/dashboard/
访问 V2 仪表板(Traefik 在 docker 容器中运行,8080 暴露给主机)。
我想更改它,以便仪表板在 http://traefik.my.server/dashboard
我尝试添加以下标签来配置此行为,但在访问 http://traefik.my.server/dashboard
404
- traefik.http.routers.dashboard.rule=Host(`traefik.my.server:`) && Path(`/dashboard`)
- traefik.http.services.dashboard.loadbalancer.server.port=8080
- traefik.http.routers.dashboard.entryPoints=http
(http
入口点是端口 80
)
设置这种重定向的正确方法是什么
推荐阅读:
- https://docs.traefik.io/v2.1/operations/dashboard/#secure-mode
- https://blog.containo.us/traefik-2-0-docker-101-fc2893944b9d
- https://github.com/containous/blog-posts/tree/master/2019_09_10-101_docker
仅供参考,这不是重定向,而是路由。
https://community.containo.us/t/how-to-redirect-to-the-dashboard-from-a-url/4082/2
跟进@Idez 在 https://community.containo.us/t/how-to-redirect-to-the-dashboard-from-a-url/4082 的帮助,一个有效的配置是
docker-compose
文件:
services:
traefik:
container_name: traefik
image: traefik
ports:
- 80:80
- 443:443
restart: unless-stopped
volumes:
- /etc/docker/container-data/traefik:/etc/traefik
- /var/run/docker.sock:/var/run/docker.sock
- /etc/localtime:/etc/localtime:ro
labels:
- traefik.http.routers.api.rule=Host(`traefik.mydomain.org`)
- traefik.http.routers.api.service=api@internal
- traefik.http.routers.api.middlewares=lan
- traefik.http.middlewares.lan.ipwhitelist.sourcerange=192.168.10.0/24, 192.168.20.0/24
- traefik.enable=true
version: "3"
配置文件
global:
sendAnonymousUsage: true
entryPoints:
http:
address: ":80"
https:
address: ":443"
api:
dashboard: true
providers:
docker:
endpoint: "unix:///var/run/docker.sock"
exposedByDefault: false
defaultRule: "Host(`{{ index .Labels \"com.docker.compose.service\" }}.mydomain.org`)"
log:
level: INFO
#level: DEBUG
certificatesResolvers:
le:
acme:
email: le@mydomain.org
storage: /etc/traefik/acme.json
tlsChallenge: {}
#caServer: "https://acme-staging-v02.api.letsencrypt.org/directory"