molezz BAR

molezz BAR

记录下那些感想 #book #biotech #software

DNSEXIT免费二级域名及SSL证书自动化API部署

image

X 上看到 @geekbb 推荐的免费二级域名,注册了试试。 然后发现虽然不能改成 CF 解析,但是他家的 API 功能还是很全的,包括 DDNS 和 SSL。

注册成功后,可以在 “Settings” 里点击 “DNS API Key” 新建一个 API key,之后就能在 linux 里设置各种自动化部署了,对我主要是自动免费 SSL 证书申请和部署。

首先在 "DOMAINS" 菜单里点击 "Free SSL Certificates" 启用新注册的域名的 SSL,然后在 vps 里新建三个 json 文件用于自动化更新和下载证书,例如建立在 /etc。

  • renew.json
{
   "apikey": "api key",
   "domain": "xx.work.gd",
   "action": "renew",
   "verbose": "true"
}
  • cert.json
{
   "apikey": "api key",
   "domain": "xx.work.gd",
   "action": "download",
   "file": "cert"
}
  • key.json
{
   "apikey": "api key",
   "domain": "xx.work.gd",
   "action": "download",
   "file": "privatekey"
}

最后通过 bash 命令进行更新,并下载到文件,可以在 cron 中设置每月定期运行。 其中@/etc/xxx.json需改成自己的路径。

# 更新证书
curl -H "Content-Type: application/json" --data @/etc/renew.json https://api.dnsexit.com/dns/lse.jsp

# 下载证书和key并存储到指定路径,如nginx
curl -H "Content-Type: application/json" --data @/etc/cert.json https://api.dnsexit.com/dns/lse.jsp > /nginx/cert.crt

curl -H "Content-Type: application/json" --data @/etc/key.json https://api.dnsexit.com/dns/lse.jsp > /nginx/key.key

更多命令如申请证书和 CA 文件请见官方文档,DDNS 命令见文档

加载中...
此文章数据所有权由区块链加密技术和智能合约保障仅归创作者所有。