前端仅侦听某些容器的根路径

时间:2019-02-23 19:10:09

标签: traefik

此问题是我之前的问题(Traefik doesn't route to proper backend for some containers)的更新。我在更新基础代码时创建了新代码:

我有2个容器:  -搬运工;  -家庭助理; 如果使用PathPrefixStrip匹配器“ / hass”,Portainer可以正常工作,但homeassistant不能正确路由到后端。但是当我使用“ PathPrefixStrep:/”时,它可以工作。容器将成为默认的服务侦听根路径,这不是预期的。我试图重定向,但没有成功。 Traefik版本:1.7.9。 Docker版本:18.09.2 Docker-compose:1.23.2
我的docker-compose:

  portainer:
    image: portainer/portainer
    container_name: portainer
    domainname: ${DOMAINNAME}
    hostname: portainer
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - ${USERDIR}/dockerha/uavportainer/data:/data
      - ${USERDIR}/dockerha/shared:/shared
    environment:
      - TZ=${TZ}
    networks:
      - ${NETWORK_NAME}
    labels:
      - "traefik.enable=false"

  homeassistant:
    image: homeassistant/home-assistant
    container_name: homeassistant
    domainname: ${DOMAINNAME}
    hostname: homeassistant
    volumes:
      - ${USERDIR}/dockerha/uavha:/config
      - /etc/localtime:/etc/localtime:ro
      - ${USERDIR}/dockerha/shared:/shared
    environment:
      - PUID=${PUID}
      - PGID=${PGID}
      - TZ=${TZ}
    networks:
      - ${NETWORK_NAME}
    labels:
      - "traefik.enable=false"

我正在使用文件提供以及单独的Rules.toml文件

# rules.toml
[frontends]
  [frontends.portainer]
  entrypoints = ["http"]
  backend = "portainer"
  passHostHeader = true
    [frontends.portainer.routes.route_1]
    rule = "Host: 192.168.56.102; PathPrefixStrip: /portainer"

[backends]
  [backends.portainer]
    [backend.portainer.servers]
      [backends.portainer.servers.server1]
      url = "http://portainer:9000"
      weight = 2
    [backends.portainer.loadBalancer]
      method = "drr"

  [frontends.hass]
  entrypoints = ["http"]
  backend = "hass"
  passHostHeader = true
    [frontends.hass.routes.route_1]
    rule = "Host: 192.168.56.102; PathPrefixStrip: /hass"

  [backends.hass]
    [backend.hass.servers]
      [backends.hass.servers.server1]
      url = "http://homeassistant:8123"
      weight = 2
    [backends.hass.loadBalancer]
      method = "drr"

提前感谢您的支持。

0 个答案:

没有答案