本文首发链接
查看我的个人博客:https://hubinqiang.com
利用certbot
工具配置Let’s encrypt通配符证书,所域名下所有的子域名都能方便的使用 https
证书,而且完全免费。值得关注的是,Let’s encrypt通配符证书只是针对二级域名,并不能针对主域名,如*.hubinqiang.com
和hubinqiang.com
被认为是两个域名,如果和我一样使用的是主域名,在申请的时候需要注意都要申请。
配置环境
操作系统:Ubuntu16.04 LTS
配置域名:hubinqiang.com,*.hubinqiang.com
步骤
1. 获取Certbot
# 下载
wget https://dl.eff.org/certbot-auto
# 设为可执行权限
chmod u+x certbot-auto
2. 申请证书
执行
./certbot-auto certonly -d "*.hubinqiang.com" -d "hubinqiang.com" --manual --preferred-challenges dns-01 --server https://acme-v02.api.letsencrypt.org/directory
参数说明:
-certonly
,表示安装模式,Certbot 有安装模式和验证模式两种类型的插件。-manual
,表示手动安装插件,Certbot 有很多插件,不同的插件都可以申请证书,用户可以根据需要自行选择。-d
,为哪些主机申请证书,如果是通配符,输入 *.hubinqiang.com(替换为自己的域名)。-preferred-challenges
,使用 DNS 方式校验域名所有权。-server
,Le