从traefik中的WSS到WS失败,并带有phantombot映像

时间:2019-05-08 21:18:09

标签: traefik

我正在尝试使用traefik为phantombot提供docker化版本,并让traefik处理ssl的证书。 由于phantombot使用websocket,因此在外部连接时只能通过wss访问websocket本身,但是在内部网络上,由于phantombot以http模式运行,因此它被列为ws。

我试图在wss的端口82处创建一个入口点,该入口点在toml中如下所示:

[entryPoints.panel]
 adress = ":82"
 [entryPoints.panel.tls]
 [[entryPoints.panel.tls.certificates]]
  certFile = "/cert.pem"
  keyFile = "/privkey.pem"

以及机器人的docker-compose中的相​​应标签:

  - traefik.panel.frontend.rule=Host:my.domain.com
  - traefik.panel.frontend.entryPoints=panel
  - traefik.panel.frontend.protocol=ws
  - traefik.panel.port=82

机器人容器上的暴露端口:

expose:
  - 80
  - 81
  - 82

我尝试过更改协议,使其变得通俗易懂,但似乎无济于事。每次尝试连接时,浏览器都会出现错误消息,指出wss://my.domain.com:82 /没有应答,并且在机器人界面中出现HTTP(500):管道损坏。 我没办法。 如果有人可以帮助我,那就太好了:)

编辑:docker-trapose组成

version: '3'

services:

  traefik:
    image: traefik:latest
    container_name: traefik
    ports:
      - "80:80"
      - "443:443"
      - "8080:8080"
      - "81:81"
      - "82:82"
    networks:
      - web
    volumes:
      - ./traefik.toml:/etc/traefik/traefik.toml
      - ./traefik.log:/etc/traefik/traefik.log
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - /etc/letsencrypt/live/my.domain.com/cert.pem:/cert.pem
      - /etc/letsencrypt/live/my.domain.com/privkey.pem:/privkey.pem

    labels:
      - traefik.frontend.rule=Host:monitor.my.domain.com
      - traefik.port=8080
      - traefik.docker.network=web
      - traefik.enable=true
      - traefik.frontend.auth.basic.users=user:pass

networks:
  web:
    external: true

特拉菲克·托姆:

# uncomment this line to get debug info with "docker logs":
#debug = true

defaultEntryPoints = ["https","http"]
[traefikLog]
  filePath = "/etc/traefik/traefik.log"
  format   = "json"

# The syntax is somewhat esoteric so this is mostly copy-paste
[entryPoints]
  [entryPoints.http]
  address = ":80"
    [entryPoints.http.redirect]
    entryPoint = "https"
  [entryPoints.https]
  address = ":443"
  [entryPoints.https.tls]
      [[entryPoints.https.tls.certificates]]
      certFile = "/cert.pem"
      keyFile = "/privkey.pem"
  [entryPoints.ytplayer]
     adress = ":81"
     [entryPoints.ytplayer.tls]
        minVersion = "VersionTLS12"
        cipherSuites = [
           "TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305",
           "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",
           "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384"
        ]
        sniStrict = true
        OSCPMustStaple = true
       [[entryPoints.ytplayer.tls.certificates]]
          certFile = "/cert.pem"
          keyFile = "/privkey.pem"
  [entryPoints.panel]
     adress = ":82"
     [entryPoints.panel.tls]
        minVersion = "VersionTLS12"
        cipherSuites = [
           "TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305",
           "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",
           "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384"
        ]
     sniStrict = true
     OSCPMustStaple = true
     [[entryPoints.panel.tls.certificates]]
      certFile = "/cert.pem"
      keyFile = "/privkey.pem"


[docker]
    endpoint = "unix:///var/run/docker.sock"
    domain = "morellenoir.de"
    watch = true
    exposedbydefault = false

# enable web configuration backend.
[web]

# Web administration port, proxied in docker-compose.yml
address = ":8080"

1 个答案:

答案 0 :(得分:0)

#traefik configuration
defaultEntryPoints = ["https","http"]
[api]
  entryPoint = "traefik"
  dashboard = true
  address = ":8080"

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