当端口8080未打开时,Traefik仪表板不显示

时间:2019-02-13 16:10:01

标签: docker docker-compose traefik

我正在学习traefik,我尝试在未打开端口8080的情况下设置仪表板。

使用以下配置,我可以访问仪表板。

docker-compose.yml

version: '3'

services:
  reverse-proxy:
    image: traefik:1.7.9-alpine
    restart: unless-stopped
    networks:
      - mynet
    ports:
      - "80:80"
      - "8080:8080"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - /opt/traefik/traefik.toml:/traefik.toml
networks:
  mynet:
    external: true

traefik.toml

[entryPoints]
    [entryPoints.http]
    address = ":80"

[api]

[docker]

从docker-compose.yml中删除端口8080后,我将无法再访问它。

进行这种非常简单的设置需要缺少哪些部分?

2 个答案:

答案 0 :(得分:0)

信息中心的网址默认为 {您的ip}:8080

我认为您可能在这里混淆了一些事情:您修改的entryPoints是“ http”,而不是“ api”。因此,使用此conf,您仍然需要通过8080访问仪表板。

如果要更改此事实,请为api添加一个入口点(例如“ foo”),然后将entryPoints.foo设置为匹配的配置。

[entryPoints]
  [entryPoints.http]
  address = ":8090"

  [entryPoints.foo]
  address = ":80"

[api]
entryPoint = "foo"

但是如您所见,您松开了“ http”默认端口...这很烦人。因此,我认为您可以保留8080或在此处改用不太容易猜到的那个。

这主要来自this part of the doc

答案 1 :(得分:0)

多亏了Marvin的帮助,我做到了:

docker-compose.yml

version: '3'

services:
  reverse-proxy:
    image: traefik:1.7.9-alpine
    restart: unless-stopped
    networks:
      - mynet
    ports:
      - "80:80"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - /opt/traefik/traefik.toml:/traefik.toml
networks:
  mynet:
    external: true

traefik.toml

[entryPoints]
 [entryPoints.http]
  address = ":80"

[api]
dashboard = true

[file]
  [backends]
    [backends.traefik]
      [backends.traefik.servers.server]
      url = "http://127.0.0.1:8080"

  [frontends]
    [frontends.traefik]
    entryPoints = ["http"]
    backend = "traefik"
      [frontends.traefik.routes.traefik]
      rule = "PathPrefixStrip:/traefik;PathPrefix:/traefik"

[docker]

转到yourdomain.tld / traefik会显示仪表板!