Let's Encrypt WebApp Renewer 使用教程
1、项目介绍
letsencrypt-webapp-renewer 是一个用于自动续订 Azure Web App SSL 证书的命令行工具。它基于 letsencrypt-azure-core,提供了以下功能:
- 支持在任意 Web App 上安装,不限于同一 Web App。
- 支持管理多个 Web App 的 SSL 证书。
- 通过 SendGrid 内置了电子邮件通知功能。
- 无外部依赖,仅依赖 Let's Encrypt。
该项目建议使用 Microsoft 托管的免费证书,但如果你需要自托管证书续订,letsencrypt-webapp-renewer 是一个不错的选择。
2、项目快速启动
安装
-
克隆项目仓库:
git clone https://github.com/ohadschn/letsencrypt-webapp-renewer.git cd letsencrypt-webapp-renewer -
下载最新的 WebJob zip 文件并部署到你的 Web App:
# 下载最新版本 wget https://github.com/ohadschn/letsencrypt-webapp-renewer/releases/latest/download/letsencrypt-webapp-renewer.zip # 部署到 Web App az webapp deployment source config-zip --resource-group <your-resource-group> --name <your-webapp-name> --src letsencrypt-webapp-renewer.zip
配置
-
创建一个新的 AAD 服务主体,并记录以下参数:
- SubscriptionId
- TenantId
- ResourceGroup
- WebApp
- ClientId
- ClientSecret
-
配置 Web App 设置:
Set-LetsEncryptConfiguration.ps1 -SubscriptionId <your-subscription-id> -TenantId <your-tenant-id> -ResourceGroup <your-resource-group> -WebApp <your-webapp-name> -ClientId <your-client-id> -ClientSecret <your-client-secret>
运行
-
设置 CRON 定时任务以自动续订证书:
# 编辑 WebJob 的 settings.job 文件 { "schedule": "0 0 1 * * *" # 每月1号0点执行 } -
部署 WebJob:
az webapp deployment source config-zip --resource-group <your-resource-group> --name <your-webapp-name> --src letsencrypt-webapp-renewer.zip
3、应用案例和最佳实践
应用案例
- 企业内部 Web 应用:企业内部使用的 Web 应用需要 SSL 证书,但不想手动管理证书续订。
- 多租户 SaaS 平台:SaaS 平台需要为每个租户自动续订 SSL 证书,确保安全性和合规性。
最佳实践
- 使用专用 Web App:为证书续订创建一个专用的 Web App,避免与其他应用部署冲突。
- 定期测试:定期手动触发证书续订任务,确保配置正确且无误。
- 监控和日志:配置监控和日志记录,及时发现和解决续订失败的问题。
4、典型生态项目
- Azure Web Apps:
letsencrypt-webapp-renewer主要用于 Azure Web Apps,与 Azure 生态紧密集成。 - Let's Encrypt:依赖 Let's Encrypt 提供的免费 SSL 证书服务。
- SendGrid:通过 SendGrid 发送续订成功或失败的通知邮件。
通过以上步骤,你可以快速上手并使用 letsencrypt-webapp-renewer 管理 Azure Web App 的 SSL 证书续订。
创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考



