Linode 实例 SSL 安装和使用 Cloudflare 自动分配 DNS

发布于 2025-01-14 02:36:36 字数 1397 浏览 2 评论 0原文

这是我的实现。

resource "linode_instance" "server" {
  count  = 1
  label  = "server-${count.index}"
  region = "ap-west"
  image  = "linode/ubuntu21.10"
  type   = "g6-nanode-1"
  tags   = ["prod"]
  root_pass      = var.linode_instance_root_password
  stackscript_id = linode_stackscript.nodejs_script.id
  stackscript_data = {
   "dns" = "server-${count.index}"
   "email" = var.ssl_certificate_email
  }
}

resource "cloudflare_record" "server" {
  zone_id = var.cloudflare_zone_id
  name    = "server-${count.index}"
  count   = "${length(linode_instance.server)}"
  value   = "${linode_instance.server[count.index].ip_address}"
  ttl     = 1
  type    = "A"
}

我可以在 Linode 脚本中使用 certbot 创建certificate.pem 和 private key.pem 文件,但是由于我在创建 Linode 实例后创建了 DNS 资源,所以不可能这样做。这方面的最佳实践是什么?

注意:我还尝试创建通配符认证(如此处所述),但我不确定如何将证书文件复制到我的服务器?

更新

sudo apt-get --assume-yes install certbot
# <UDF name="dns" label="System Package to Install" example=“server" default="">
sudo certbot certonly --standalone --non-interactive --agree-tos -m [email protected] -d $DNS

Here it’s my implementation.

resource "linode_instance" "server" {
  count  = 1
  label  = "server-${count.index}"
  region = "ap-west"
  image  = "linode/ubuntu21.10"
  type   = "g6-nanode-1"
  tags   = ["prod"]
  root_pass      = var.linode_instance_root_password
  stackscript_id = linode_stackscript.nodejs_script.id
  stackscript_data = {
   "dns" = "server-${count.index}"
   "email" = var.ssl_certificate_email
  }
}

resource "cloudflare_record" "server" {
  zone_id = var.cloudflare_zone_id
  name    = "server-${count.index}"
  count   = "${length(linode_instance.server)}"
  value   = "${linode_instance.server[count.index].ip_address}"
  ttl     = 1
  type    = "A"
}

I can create the certificate.pem and private key.pem files with certbot in Linode Script however since I create the DNS resource after the Linode instance creation it’s not possible to do that. What are the best practices for this?

Note: I've also tried to create wildcard certification (as explained in here) but I'm not sure how can I copy the certificate files to my servers?

Update

sudo apt-get --assume-yes install certbot
# <UDF name="dns" label="System Package to Install" example=“server" default="">
sudo certbot certonly --standalone --non-interactive --agree-tos -m [email protected] -d $DNS

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文