给七牛云域名添加 https 证书

12 个月前
/
28

本文以腾讯云服务为例,介绍如何给七牛云自定义域名添加 https 证书。

关于 certbot 的安装,请参考官方文档:certbot.eff.org

一、先将域名指定到云服务器

添加一条 A 类型的解析记录,指定到云服务器实例 IP:

picture 0

picture 0

二、配置云服务器 Nginx

配置 Nginx 的原因是 Let's Encrypt 需要验证网站的所有权才能颁发证书,我们使用 HTTP-01 的方式:

# nginx.conf
server {
    listen 80;
    server_name cdn.example.com;
    
    location ^~  /.well-known/acme-challenge/ {
        default_type "text/plain";
        root  /home/letsencrypt/;
    }
}

重启 Nginx 服务:

nginx -s reload

三、签发证书

certbot certonly --email xxx@xxx.com --webroot -w /home/letsencrypt -d cdn.example.com

输出以下结果,代表签发成功:

picture 2

picture 2

四、上传证书

picture 3

picture 3

五、将域名指向七牛云

将刚刚添加的 A 类型解析记录修改为 CNAME 类型,值填写七牛云的域名(xxxxxx-asdfc.qiniudns.com):

picture 4

picture 4
  • Loading...
  • Loading...
  • Loading...
  • Loading...