Files
Deployments/acme/实例研究1.md

118 lines
3.2 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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.
## 背景说明
a. 研究frps服务器的acme部署情况。
时隔久远重新确认frps服务器的证书安装途径和现状。
b. 将gitea部署到现在frps的服务器上。
## 确认acme的状态
1. 确认当前证书
`acme.sh --list`
[root@ngork ~]# acme.sh --list
Main_Domain KeyLength SAN_Domains CA Created Renew
dev.woyue.org "" *.dev.woyue.org ZeroSSL.com Sat Sep 18 16:42:15 UTC 2021 Wed Nov 17 16:42:15 UTC 2021
2. 确认自动更新
`crontab -e`
o1 0 * * * "/root/.acme.sh"/acme.sh --cron --home "/root/.acme.sh" > /dev/null
3. 查找acme.sh文件
`find / -name acme.sh`
可以定位到当前服务器,这个文件位于:
/root/.acme.sh/acme.sh
这里要注意ls是显示不出来.acme.sh的可以直接cd .acme.sh
4. 查看.acme.sh目录下的内容
[root@ngork .acme.sh]# ls -l
total 240
-rw-r--r-- 1 root root 315 Sep 19 00:42 account.conf
-rwxr-xr-x 1 root root 205958 Jul 20 11:50 acme.sh
-rw-r--r-- 1 root root 78 May 17 2020 acme.sh.csh
-rw-r--r-- 1 root root 78 May 17 2020 acme.sh.env
drwxr-xr-x 4 root root 4096 Jul 20 11:50 ca
drwxr-xr-x 2 root root 4096 Jul 20 11:50 deploy
drwxr-xr-x 3 root root 4096 May 19 2020 dev.woyue.org
drwxr-xr-x 2 root root 4096 Jul 20 11:50 dnsapi
-rw-r--r-- 1 root root 252 Oct 27 00:41 http.header
drwxr-xr-x 2 root root 4096 Jul 20 11:50 notify
其中account.conf中有阿里云的具有DNS操作权限的账户的key和secret。
## 添加证书
1. 申请安装证书。加--debug参数可以显示更多细节
`acme.sh --debug --issue --dns dns_ali -d git.woyue.org`
2. 安装完毕后,检验是否配置自动任务
`crontab -e`
3. 确认当前证书
`acme.sh --list`
## 安装证书
1. 复制证书:
`mkdir -p /srv/certbot/conf/live/git.woyue.org`
`acme.sh --installcert -d git.woyue.org \
--key-file /srv/certbot/conf/live/git.woyue.org/privkey.pem \
--fullchain-file /srv/certbot/conf/live/git.woyue.org/fullchain.pem \
--reloadcmd "docker restart nginx_nginx_1"`
注意最后的nginx_nginx_1或nginx_server为nginx容器的名称。请根据实际情况修改。**或不加此参数手动重启nginx**。
2. 生成dhparams文件
`openssl dhparam -out /srv/certbot/conf/ssl-dhparams.pem 2048`
## 使用证书
例如要使用上述证书则nginx的docker对应etc/letsencrypt的目录就是/srv/certbot/conf。比如说conf文件里引用的密钥文件路径为
ssl_certificate /etc/letsencrypt/live/git.woyue.org/fullchain.pem
那么docker mount的路径就应该是-v /srv/certbot/conf:/etc/letsencrypt
为此检查一下当前的nginx的volume:
`docker inspect nginx_nginx_1`
能看到:
......
"Mounts": [
......
{
"Type": "bind",
"Source": "/srv/certbot/conf",
"Destination": "/etc/letsencrypt",
"Mode": "rw",
"RW": true,
"Propagation": "rprivate"
},
......
可见当前的nginx docker实例配置已经满足要求。
## 后续
参看Gitea项目的Readme。