Traefik 2和Bitwarden RS协议在通知/集线器上

时间:2019-10-20 15:34:52

标签: websocket docker-compose traefik

我正在使用traefik 2.0(v2),并且正在尝试在serv上配置bitwardenrs。

这是我的docker-compose.yml:

version: "3"

services:
  bitwarden:
    image: bitwardenrs/server
    restart: always
    volumes:
      - ./bw-data:/data
    environment:
      WEBSOCKET_ENABLED: "true" # Required to use websockets
      SIGNUPS_ALLOWED: "false"
      ADMIN_TOKEN: "myadmintoken"
    networks:
      - traefik_network
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.bitwardenRouter.rule=Host(`mywebsite.com`)"
      - "traefik.http.routers.bitwardenRouter.entrypoints=web-secured"
      - "traefik.http.routers.bitwardenRouter.tls=true"
      - "traefik.http.routers.bitwardenRouter.tls.options=default"
      - "traefik.http.routers.bitwardenRouter.tls.certResolver=letsencrypt"

networks:
  traefik_network:
    external: true

当我这样做时,我遇到一个错误:

bitwarden_1  | [2019-10-20 15:12:07][rocket::rocket][INFO] POST /notifications/hub/negotiate text/plain; charset=UTF-8:
bitwarden_1  | [2019-10-20 15:12:07][_][INFO] Matched: POST /notifications/hub/negotiate (negotiate)
bitwarden_1  | [2019-10-20 15:12:07][rocket::rocket][INFO] GET /api/sync?excludeDomains=true application/json:
bitwarden_1  | [2019-10-20 15:12:07][_][INFO] Matched: GET /api/sync?<data..> (sync)
bitwarden_1  | [2019-10-20 15:12:07][_][INFO] Outcome: Success
bitwarden_1  | [2019-10-20 15:12:07][_][INFO] Response succeeded.
bitwarden_1  | [2019-10-20 15:12:07][_][INFO] Outcome: Success
bitwarden_1  | [2019-10-20 15:12:07][_][INFO] Response succeeded.
bitwarden_1  | [2019-10-20 15:12:07][rocket::rocket][INFO] GET /notifications/hub?id=myId&access_token=myToken:
bitwarden_1  | [2019-10-20 15:12:07][_][INFO] Matched: GET /notifications/hub (websockets_err)
bitwarden_1  | [2019-10-20 15:12:07][bitwarden_rs::error][ERROR] '/notifications/hub' should be proxied to the websocket server or notifications won't work. Go to the README for more info.. '/notifications/hub' should be proxied to the websocket server or notifications won't work. Go to the README for more info.

这是错误:

[2019-10-20 15:12:07][bitwarden_rs::error][ERROR] '/notifications/hub' should be proxied to the websocket server or notifications won't work. Go to the README for more info.. '/notifications/hub' should be proxied to the websocket server or notifications won't work. Go to the README for more info.

我试图找到方法,使用traefik 1.7我发现了这一点:

- traefik.hub.frontend.rule=Host:bitwarden.domain.tld;Path:/notifications/hub
- traefik.hub.port=3012
- traefik.hub.protocol=ws

但这不适用于traefik的V2。我在问这个,但是也不能用:

- "traefik.http.routers.notificationBitwardenRouter.rule=(Host(`mywebsite.com`) && Path(`/notifications/hub`))"
- "traefik.http.routers.notificationBitwardenRouter.entrypoints=web-secured"
- "traefik.http.services.notificationBitwardenRouter.loadbalancer.server.port=3012"
- "traefik.http.services.notificationBitwardenRouter.loadbalancer.server.protocol=ws"
- "traefik.http.services.notificationBitwardenService.loadBalancer.servers=0.0.0.0:3012"

有人可以帮我吗?

1 个答案:

答案 0 :(得分:1)

https://github.com/dani-garcia/bitwarden_rs/wiki/Proxy-examples已使用traefik v2更新。

Traefik v1标签迁移到Traefik v2

labels:
  - traefik.enable=true
  - traefik.docker.network=traefik
  - traefik.http.routers.bitwarden-ui.rule=Host(`bitwarden.domain.tld`)
  - traefik.http.routers.bitwarden-ui.service=bitwarden-ui
  - traefik.http.services.bitwarden-ui.loadbalancer.server.port=80
  - traefik.http.routers.bitwarden-websocket.rule=Host(`bitwarden.domain.tld`) && Path(`/notifications/hub`)
  - traefik.http.routers.bitwarden-websocket.service=bitwarden-websocket
  - traefik.http.services.bitwarden-websocket.loadbalancer.server.port=3012

迁移的标签加上HTTP到HTTPS重定向

这些标签假定在Traefik中为端口80和443定义的入口点分别是“ web”和“ websecure”。

这些标签还假定您已经在Traefik中定义了默认的证书解析器。

labels:
  - traefik.enable=true
  - traefik.docker.network=traefik
  - traefik.http.middlewares.redirect-https.redirectScheme.scheme=https
  - traefik.http.middlewares.redirect-https.redirectScheme.permanent=true
  - traefik.http.routers.bitwarden-ui-https.rule=Host(`bitwarden.domain.tld`)
  - traefik.http.routers.bitwarden-ui-https.entrypoints=websecure
  - traefik.http.routers.bitwarden-ui-https.service=bitwarden-ui
  - traefik.http.routers.bitwarden-ui-http.rule=Host(`bitwarden.domain.tld`)
  - traefik.http.routers.bitwarden-ui-http.entrypoints=web
  - traefik.http.routers.bitwarden-ui-http.middlewares=redirect-https
  - traefik.http.routers.bitwarden-ui-http.service=bitwarden-ui
  - traefik.http.services.bitwarden-ui.loadbalancer.server.port=80
  - traefik.http.routers.bitwarden-websocket-https.rule=Host(`bitwarden.domain.tld`) && Path(`/notifications/hub`)
  - traefik.http.routers.bitwarden-websocket-https.entrypoints=websecure
  - traefik.http.routers.bitwarden-websocket-https.service=bitwarden-websocket
  - traefik.http.routers.bitwarden-websocket-http.rule=Host(`bitwarden.domain.tld`) && Path(`/notifications/hub`)
  - traefik.http.routers.bitwarden-websocket-http.entrypoints=web
  - traefik.http.routers.bitwarden-websocket-http.middlewares=redirect-https
  - traefik.http.routers.bitwarden-websocket-http.service=bitwarden-websocket
  - traefik.http.services.bitwarden-websocket.loadbalancer.server.port=3012