【发布时间】: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