前言
本教程使用 acme.sh 申请 Let’s Encrypt 免费证书,并实现自动续期与自动部署到 OpenList。
默认你已经:
- 使用 Docker 部署 OpenList
- 拥有自己的域名
- 能正常 HTTP 访问 OpenList
教程以
Cloudflare
腾讯云 DNSPod
阿里云 DNS 这些平台为利。
如果你不喜欢命令行,也可以使用
Lucky 、1Panel、宝塔等面板申请证书。
一、SSH 登录服务器
后面的所有命令都需要在 OpenList 所在服务器执行。
可以使用:
- CMD
- PuTTY
连接服务器:
ssh root@你的服务器IP二、安装 acme.sh
官方项目:
acme.sh Github
安装:
curl https://get.acme.sh | sh加载环境:
source ~/.bashrc三、配置 DNS API
本教程使用 DNS 验证申请证书。
因为国内大多数家庭宽带的 IPv4 80/443 端口通常会被运营商限制,DNS 验证会更稳定。
acme.sh DNS API 文档:
acme.sh DNS API Wiki
Cloudflare
export CF_Token="你的token"
export CF_Account_ID="你的account_id"
export CF_Zone_ID="你的zone_id"申请时使用:--dns dns_cf
阿里云 DNS
export Ali_Key="你的AccessKey"
export Ali_Secret="你的Secret"申请时使用:--dns dns_ali
DNSPod(腾讯云)
export DP_Id="你的ID"
export DP_Key="你的Token"申请时使用:--dns dns_dp
四、申请 HTTPS 证书
推荐 ECC 证书:
acme.sh --issue -d ot.example.com --dns dns_cf --keylength ec-256如果你使用阿里云 DNS:
acme.sh --issue -d ot.example.com --dns dns_ali --keylength ec-256如果你使用 DNSPod:
acme.sh --issue -d ot.example.com --dns dns_dp --keylength ec-256五、部署证书到 OpenList
假设 OpenList 数据目录:
/container/openlist/data/cert
执行:
acme.sh --install-cert -d ot.example.com \
--ecc \
--key-file /container/openlist/data/cert/private.key \
--fullchain-file /container/openlist/data/cert/fullchain.crt \
--reloadcmd "docker restart openlist"六、确认部署是否成功
查看:
acme.sh --info -d ot.example.com正常应该看到:
- Le_RealKeyPath=/container/openlist/data/cert/private.key
- Le_RealFullChainPath=/container/openlist/data/cert/fullchain.crt
- Le_ReloadCmd=docker restart openlist
七、配置 OpenList HTTPS
编辑:
/container/openlist/data/config.json
找到:
“https_port”: -1
修改为:
“https_port”: 5245
然后添加:
“cert_file”: “/opt/openlist/data/cert/fullchain.crt”,
“key_file”: “/opt/openlist/data/cert/private.key”
注意:
这里必须写 Docker 容器内部路径,不是宿主机路径。
八、开放 HTTPS 端口
Docker 必须映射 HTTPS 端口:
例如:
docker run -d \
--name openlist \
-p 5244:5244 \
-p 5245:5245 \
-v /vol1/containers/openlist/data:/opt/openlist/data \
openlistteam/openlist九、重启 OpenList
docker restart openlist十、访问 HTTPS
https://你的域名:5245
十一、检查证书
查看本地证书:
cd /container/openlist/data/cert
openssl x509 -in fullchain.crt -noout -issuer -subject -dates查看线上真实证书:
echo | openssl s_client -connect 你的域名:5245 -servername 你的域名 2>/dev/null | openssl x509 -noout -dates十二、测试自动续期
强制模拟续期:
acme.sh --renew -d 你的域名 --ecc --force正常应该看到:
- Installing key to:
- Installing full chain to:
- Run reload cmd: docker restart openlist
十三、检查自动续期
查看:
crontab -l正常应该有:
“/root/.acme.sh”/acme.sh –cron
说明 acme.sh 已开启自动续期。
十四、常用证书命令
查看证书时间:
openssl x509 -in fullchain.crt -noout -dates查看完整信息:
openssl x509 -in fullchain.crt -noout -issuer -subject -dates查看线上证书:
echo | openssl s_client -connect 域名:443 -servername 域名 2>/dev/null | openssl x509 -noout -dates

