2023-06-29 11:55:02 +08:00

49 lines
1.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

## 地址
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即可之后输入
```bash
export CF_Key="19db67256c0eca16b5f4f4e8a7150c00eec16"
export CF_Email="378100977@qq.com"
```
```bash
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
```