无法从docker容器访问traefik代理的站点

时间:2018-09-03 13:50:56

标签: docker traefik

如果使用端口号,我可以从服务机访问站点;例如http://localhost:8080,但是如果我从局域网以外尝试使用url,则将无法使用。 我有一个适用于traefik的前端规则,但不适用于其他容器。

docker-compose.yml:

version: "2"
services:
  traefik:
    image: traefik:latest
    command: --api --docker --logLevel=DEBUG
    hostname: mysite.ddns.net
    restart: unless-stopped
    networks:
      - web
      - bridge
    ports:
      - 80:80
      - 8080:8080
      - 443:443
    labels:
      - "traefik.docker.network=web"
      - "traefik.enable=true"
      - "traefik.backend=traefik"
      - "traefik.frontend.rule=Host:${DOMAINNAME}; PathPrefixStrip: /traefik"
      - "traefik.port=8080"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - "/docker/traefikcompose/traefik.toml:/etc/traefik/traefik.toml"
      - /docker/traefikcompose:/etc/traefik:rw
    container_name: traefik
networks:
  web:
    external: true
  bridge:
    external: false

traefik.toml:

traefikLogsFile = "log/traefik.log"
accessLogsFile = "log/access.log"
ProvidersThrottleDuration = "5s"
MaxIdleConnsPerHost = 200

debug = true
logLevel = "ERROR"

[entryPoints]
  [entryPoints.http]
    address = ":80"
  [entryPoints.http.redirect]
    entryPoint = "https"

  [entryPoints.https]
    address = ":443"
[entryPoints.https.tls]

[retry]

[api]
#dashboard = true
#entryPoint = "dashboard"
address= ":8080"

[docker]
  endpoint = "unix:///var/run/docker.sock"
  #endpoint = "//var/run/docker.sock:/var/run/docker.sock"
  domain = "mysite.ddns.net"
  watch = true
  exposedbydefault = true

[acme]
  email = "mymail@gmail.com"
  #caServer = "https://acme-staging-v02.api.letsencrypt.org/directory"
  storage = "acme.json"
  entryPoint = "https"
  acmeLogging = true
  onDemand = true
  OnHostRule = true
[acme.httpChallenge]
  entryPoint = "http"
[[acme.domains]]
  main = "mysite.ddns.net"

我在单独的yml中有一个Ghost-Blog和Home-assantant:

Ghost Blog Docker-Compose:

version: "2"
services:
  ghost:
    image: ghost
    container_name: ghost
    hostname: mysite.ddns.net
    restart: unless-stopped
    networks:
      - web
      - bridge
    ports:
      - 2368:2368
    labels:
      - "traefik.docker.network=web"
      - "traefik.enable=true"
      - "traefik.backend=ghost"
      - "traefik.frontend.rule=Host:${DOMAINNAME}; PathPrefixStrip: /blog, ${DOMAINNAME}"
      - "traefik.port=2368"
    volumes:
     - "/docker/ghost/blog:/var/lib/ghost/content"
    environment:
      - NODE_ENV=production
      - url=http://mysite.ddns.net

networks:
  web:
    external: true
  bridge:
    external: false

家庭辅助Docker Compose:

version: "2"
services:
  home-assistant:
    image: homeassistant/home-assistant
    container_name: home-assistant
    hostname: mysite.ddns.net
    privileged: true
    restart: unless-stopped
    networks:
      - web
      - bridge
    ports:
      - 8123:8123
      - 8943:8943
    labels:
      - "traefik.docker.network=web"
      - "traefik.enable=true"
      - "traefik.backend=home-assistant"
      - "traefik.frontend.rule=Host:${DOMAINNAME}; PathPrefixStrip: /hass"
      - "traefik.port=8123"
      #- "traefik.basic.protocol=http"
    volumes:
      - "/docker/home-assistant/config:/config"
      - "/etc/localtime:/etc/localtime:ro"
      - "/etc/timezone:/etc/timezone:ro"
    devices:
      - "/dev/bus/usb:/dev/bus/usb"

networks:
  web:
    external: true
  bridge:
    external: false

DOMAINNAME已定义并在.env文件中工作。我已经在防火墙和路由器中打开了端口80、443、2368、8123、8080。

有什么建议吗?

0 个答案:

没有答案