【问题标题】:gcloud cmd line add ssl certificat to lbgcloud命令行将ssl证书添加到lb
【发布时间】:2018-04-03 16:07:59
【问题描述】:

我正在使用 Google Cloud Platform 负载平衡器来重定向我的 HTTP 和 HTTPS 流量。 对于 SSL 证书,我使用的是letsencrypt。 我有一个 cron 来刷新证书并将其上传到 gcloud。

我正在寻找一种在负载均衡器上添加/替换证书的方法,就像在 UI 中一样。

我当前的脚本

#!/bin/bash
# This script must be run as root or sudo

cert_path=/etc/letsencrypt/live/domain.co
project_ids=("domain-xxxxx")
date=`date +%d-%m-%Y`
certname="domain-cert-${date}"

lb_cert() {
  # Multiples projects
  for project_id in "${project_ids[@]}"; do
    gcloud config set project $project_id
    gcloud compute ssl-certificates create $certname --certificate "${cert_path}/cert.pem" --private-key "${cert_path}/privkey.pem"
  done
}

certbot renew --quiet

if [[ "$?" -ne 0 ]]; then
  lb_cert
fi

【问题讨论】:

    标签: google-cloud-platform google-compute-engine gcloud


    【解决方案1】:

    要更改 SSL 证书,您必须使用新证书更新目标 HTTP 代理:

    gcloud compute target-https-proxies update $https_proxy_name --ssl-certificates=$certname
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-09-22
      • 2017-04-21
      • 2018-12-21
      • 2018-12-26
      • 1970-01-01
      相关资源
      最近更新 更多