Traefik 2.0 TLS TCP 直通

A3e*_*eXy 3 ssl tcp traefik

我有一个 VM0,其中 Traefik 作为 Docker 运行,还有两个目标系统 VM1 和 VM2,它们都运行着 Web 服务器。

所有domainA.com 请求都应通过 TCP 路由器和 tls 直通发送至 VM1,因为此 Web 服务正在自行处理证书。

所有domainB.com 请求都应通过http 路由器发送至VM2,并且Traefik 应生成该域的tls 证书。

我现在的问题是,一旦我将任何 tls 配置添加到 http 路由器,tcp 直通似乎就不再起作用了。在日志中我看到以下消息:

time="2020-03-15T21:46:18Z" level=debug msg="为请求提供默认证书:\"subdomain.DomainA.com\"" time="2020-03-15T21:46:18Z" level= debug msg="http:来自 192.168.1.116:55103 的 TLS 握手错误:远程错误:tls:未知证书" time="2020-03-15T21:46:18Z" level=debug msg="为请求提供默认证书:\ “subdomain.DomainA.com\”” time =“2020-03-15T21:46:18Z”level = debug msg =“http:来自192.168.1.116:55104的TLS握手错误:远程错误:tls:未知证书”

如果我通过 Traefik 访问该网站,它会向我显示来自 Traefik 的自签名证书。

如果我删除 http 路由器下的所有 tls 设置,直通将再次工作。

我的动态文件:

http:
  routers:

    HTTProuter0:
      rule: "HostRegexp(`{subdomain:[a-z]+}.domainA.com`)"
      service: "domainA"
      entryPoints:
       - "websecure"
      tls:
        certResolver: "myresolver"
        domains:
         - main: "domainA.com"
           sans:
           - "*.domainA.com"
  services:

    domainA:
      loadBalancer:
        servers:
          - url: "https://192.168.1.13:4433"

tcp:
  routers:
    TCProuter0:
      rule: "HostSNI(`*`)"
      service: "domainB"
      entryPoints:
       - "websecure"
      tls:
       passthrough: true

  services:
    domainB:
      loadBalancer:
        servers:
         - address: "192.168.1.11:443"
Run Code Online (Sandbox Code Playgroud)

我的静态文件:

serversTransport:
  insecureSkipVerify: true

entryPoints:
  web:
    address: ":80"

  websecure:
    address: ":443"

  spain:
    address: ":4443"

certificatesResolvers:
  myresolver:
    acme:
      email: email@email.com
      storage: /etc/traefik/acme/acme.json
      dnsChallenge:
        provider: cloudflare
        delayBeforeCheck: 60
        resolvers:
          - "1.1.1.1:53"
          - "8.8.8.8:53"

api:
 insecure: true
 dashboard: true

providers:
 docker: {}
 file:
  directory: /etc/traefik/config
  watch: true

log:
  filePath: /etc/traefik/traefik.log
  level: DEBUG
Run Code Online (Sandbox Code Playgroud)

我现在被这个问题困扰了几个小时。我不确定这是一个错误还是我做错了什么?

任何帮助将不胜感激!

多谢

A3e*_*eXy 8

我发现了问题。难以置信,我为此浪费了这么多时间...Traefik 似乎不支持通配符与 HostSNI 中的域结合使用。

HostSNI(`*`) => 作品

HostSNI(`*.mydomain.com`)=> 不起作用!!!

HostSNI(`www.mydomain.com`,`web.mydomain.com`)=> 工作

所以我显式添加了每个域,现在它可以工作了。