【问题标题】:Internal Server Error with Traefik HTTPS backend on port 443Traefik HTTPS 后端在端口 443 上出现内部服务器错误
【发布时间】:2018-08-30 22:18:45
【问题描述】:

使用 docker,我尝试使用 HTTPS 端口 443 设置 traefik 后端,因此 traefik 容器和应用程序容器(apache 2.4)之间的通信将被加密。

如果我在我的 docker 容器上激活 traefik.protocol=httpstraefik.port=443,我会得到一个 Internal Server Error。此问题已在此处记录: https://github.com/containous/traefik/issues/2770#issuecomment-374926137

例如,完全相同的设置适用于 jwidler/nginx-proxy(在 docker hub 上提供反向代理)。容器上的证书(内部运行的 apache 2.4)是真正签名的证书(我将它们安装在 traefik 和容器的 apache 上)。如果我使用 https://... 直接请求我的 apache 容器,所有浏览器都说证书有效(绿色)。所以容器里的证书是ok的。

问题很简单: 使用InsecureSkipVerify = true 并不安全。 是否有任何生产解决方案能够使用知名权威机构(在我的情况下为 Gandi 或 Comodo)颁发的证书,使标签为 traefik.protocol=httpstraefik.port=443 的容器后端工作。

谢谢。

【问题讨论】:

    标签: traefik


    【解决方案1】:

    我猜你可能需要添加

    InsecureSkipVerify = true
    

    在主/全局部分

    请参考https://docs.traefik.io/configuration/commons/,上面写着:

    InsecureSkipVerify : If set to true invalid SSL certificates are accepted for backends.
    Note: This disables detection of man-in-the-middle attacks so should only be used on secure backend networks.
    

    【讨论】:

    • 非常感谢 :) 这让我花了好几个小时才找到你的解决方案。
    • 这在问题中被明确列为不是一个好的解决方案。在撰写此评论时,Traefik 不支持 SNI 进行后端连接,因此无法使用任何没有 IP SAN 的证书作为后端 IP。
    【解决方案2】:

    我只设法通过设置InsecureSkipVerify = true 公开了 Kubernetes 仪表板。这是我将它添加到 traefik 部署文件(最后一行)的方式:

    spec:
      serviceAccountName: traefik-ingress-controller
      terminationGracePeriodSeconds: 60
      containers:
      - image: traefik
        name: traefik-ingress-lb
        ports:
        - name: https
          containerPort: 443
        args:
        - --api
        - --kubernetes
        - --logLevel=INFO
        - --defaultentrypoints=https
        - --entrypoints=Name:https Address::443 TLS
        - --insecureSkipVerify=true
    

    【讨论】:

      【解决方案3】:

      我的问题是traefik.protocol=https;这不是启用 https 所必需的,而是直接导致了500

      【讨论】:

        【解决方案4】:

        如前所述:

        这在问题中被明确列为不是一个好的解决方案。在撰写此评论时,Traefik 不支持 SNI 用于后端连接,因此没有办法使用任何类型的证书,而没有 IP SAN 作为后端 IP。 – 拉斐尔·丰塞卡 2018 年 9 月 23 日 23:40

        https://github.com/traefik/traefik/issues/3906 解决了这个问题。

        Traefik 通过 IP 地址在节点内部与后端通信。对于那些使用的证书是无效的。

        有两种选择:

        1. Traefik 和后端之间通过 http 通信
        2. 使用--insecureSkipVerify=true 忽略证书验证

        第一种方案在入口处配置:

            apiVersion: networking.k8s.io/v1
            kind: Ingress
            metadata:
              name: some-ingress
              annotations:
                traefik.ingress.kubernetes.io/router.entrypoints: websecure
            spec:
              rules:
              - http:
                  paths:
                  - path: /
                    pathType: Prefix
                    backend:
                      service:
                        name: service-name
                        port:
                          number: 80
              tls:
              - secretName: traefik-cert
        

        第二种解决方案是通过arg设置--serversTransport.insecureSkipVerify=true

        【讨论】:

          猜你喜欢
          • 2018-09-18
          • 1970-01-01
          • 2022-12-09
          • 1970-01-01
          • 2013-01-30
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多