1.5 KiB
1.5 KiB
地址
https://github.com/acmesh-official/acme.sh
通过acme.sh脚本来设置证书
安装acme.sh
apt-get update && apt-get -y install socat //安装socat
yum install socat
wget -qO- get.acme.sh | bash //安装脚本
source ~/.bashrc
申请证书
在你的域名解析服务提供商那里添加好解析记录,假定你的域名是yourdomain.com,记得不要开启CDN,然后执行下面命令申请证书。
acme.sh --issue --standalone -d yourdomain.com -k ec-256
因为本人要有blog,需要与nginx容器共存,所以使用网站目录方式:
acme.sh --issue -d blueroses.top -d www.blueroses.top -d tj.blueroses.top -k ec-256 --webroot /root/docker/nginx/html
通配符证书申请
通配符证书只支持dns方式,这里使用CloudFlare。首先在https://dash.cloudflare.com/profile/api-tokens 申请一个Global API Token。点击Global API Key栏的View即可,之后输入:
export CF_Key="19db67256c0eca16b5f4f4e8a7150c00eec16"
export CF_Email="378100977@qq.com"
acme.sh --issue -d blueroses.top -d *.blueroses.top --dns dns_cf \
--key-file /root/docker/trojan/trojan.key \
--fullchain-file /root/docker/trojan/trojan.crt \
--reloadcmd "docker restart nginx-web trojan"
安装证书和私钥到指定位置
acme.sh --installcert -d blueroses.top \
--fullchain-file /root/docker/trojan/trojan.crt \
--key-file /root/docker/trojan/trojan.key \
--ecc --reloadcmd "docker restart nginx-web trojan"
自动续期
acme.sh --upgrade --auto-upgrade