【问题标题】:How can I get LetsEncrypt working with a wildcard domain on Traefik?如何让 LetsEncrypt 在 Traefik 上使用通配符域?
【发布时间】:2019-05-01 12:28:38
【问题描述】:

我正在尝试在我的 Traefik 实例上使用通配符域设置 LetsEncrypt。 Traefik 已从 Helm Chart stable/traefik 安装。

我们将 Google Cloud 用于 DNS,因此我想使用 gcloud 作为我的 Traefik acme 提供者。

如前所述,它是一个通配符。我正在尝试让 Traefik 使用 domain.com 作为 SAN 管理 *.domain.com 的 LetsEncrypt。

我目前正在使用 K8s 声明来存储 acme.json 文件,它已填充了私钥但没有证书。

Traefik Helm 价值观

# LetsEncrypt
acme:
  acmeLogging: true
  challengeType: 'dns-01'
  enabled: true
  domains:
    enabled: true
    main: '*.<domain>'
    sans:
        - <domain>
  defaultEntryPoints:
  - http
  - https
  dnsProvider:
    name: 'gcloud'
    gcloud:
      GCE_PROJECT: <redacted>
      GCE_SERVICE_ACCOUNT_FILE: /secrets/gcloud-credentials.json
  email: <redacted>
  entryPoint: 'https'
  entryPoints:
    http:
      address: ':80'
    https:
      address: ':443'
  persistence:
    enabled: true
    existingClaim: 'certificate-store'
  provider: 'gcloud'
  staging: true

# SSL configuration
ssl:
 enabled: true
 enforced: true

acme.json

{
  "Account": {
    "Email": "<redacted>",
    "Registration": {
      "body": {
        "status": "valid",
        "contact": [
          "mailto:<redacted>"
        ]
      },
      "uri": "https://acme-staging-v02.api.letsencrypt.org/acme/acct/9091953"
    },
    "PrivateKey": "<redacted>",
    "KeyType": "4096"
  },
  "Certificates": null,
  "HTTPChallenges": {},
  "TLSChallenges": {}
}

所有来自 Traefik 的响应都应该使用通配符 LetsEncrypt 证书,用于自动更新的域。

我可能需要执行哪些额外步骤才能让 Traefik 开始生成证书,以及如何配置 Traefik 以默认使用此证书? (而不是内置的)

谢谢

【问题讨论】:

    标签: kubernetes lets-encrypt kubernetes-helm traefik


    【解决方案1】:

    我想出了这个。 我在我的 Helm 图表中设置了以下(添加或替换上述内容)覆盖 YAML。

    acme:
      caServer: 'https://acme-v02.api.letsencrypt.org/directory'
      domains:
        enabled: true
        domainsList:
          - main: '*.<domain>'
          - sans:
              - <domain>
    

    我也摆脱了persistence.existingClaim 并让 Traefik 提出自己的主张,但如果您已经有一个现有的,保留这个定义应该不会给您带来任何问题!

    所有 Traefik 入口现在都在提供正确的 LetsEncrypt 证书,无需任何额外配置。

    感谢 Vasily Angapov 的回复 - 您在 acme.domains.domainsList 部分是正确的。 :-)

    【讨论】:

      【解决方案2】:

      您是否 100% 确定“域”节应该是这样的?在stable/traefik 图表中,我看到了另一种域格式:

        domains:
          enabled: false
          # List of sets of main and (optional) SANs to generate for
          # for wildcard certificates see https://docs.traefik.io/configuration/acme/#wildcard-domains
          domainsList:
          # - main: "*.example.com"
          # - sans:
          #   - "example.com"
          # - main: "*.example2.com"
          # - sans:
          #   - "test1.example2.com"
          #   - "test2.example2.com"
      

      但可能只是图表版本较新的问题,我不知道...如果您的图表版本较旧,那么您可以尝试升级...

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-08-07
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多