Files
Auto-ssl/README.md
T
cnbugs 2d70a15307 feat: add login authentication and certificate expiry notifications
- JWT-based login with ADMIN_USER/ADMIN_PASSWORD env config
- Login page with auth guard for Vue frontend
- Feishu bot webhook notification for expiring certificates
- SMTP email notification for expiring certificates
- Daily 8:00 AM cron for expiry checks
- Startup health check notification
2026-07-23 16:25:02 +08:00

102 lines
3.0 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.
# AutoSSL - 自动 SSL 证书管理工具
基于 Go 开发的 ACME 自动 SSL 证书申请与管理工具,提供 Web 管理界面。
## 功能
- ✅ 自动申请 SSL 证书(Let's Encrypt / ZeroSSL
- ✅ 自动续期(每天凌晨 3 点自动检查并续期)
- ✅ HTTP-01(端口 80)和 DNS-01 验证方式
- ✅ 支持阿里云 DNS / Cloudflare / DNSPod
- ✅ Web 管理界面(仪表盘、证书列表、申请、查看、续期、删除)
-**用户登录认证**JWT Token
-**证书到期通知**(飞书机器人和邮件)
- ✅ Docker 一键部署
## 快速开始
### Docker 部署
```bash
git clone <your-repo-url> autossl
cd autossl
docker compose up -d
```
访问 http://localhost:8080
### 直接运行
```bash
# 编译
cd backend && go build -o autossl .
# 运行(默认端口 8080
./autossl
```
## 环境变量
| 变量 | 默认值 | 说明 |
|------|--------|------|
| PORT | 8080 | Web 服务端口 |
| DATA_DIR | ./data | 数据存储目录 |
| CERT_DIR | ./data/certs | 证书文件存储目录 |
| ACCOUNTS_DIR | ./data/accounts | ACME 账号存储目录 |
| ACME_PORT | 8082 | HTTP-01 挑战端口 |
| ADMIN_USER | admin | 管理员用户名 |
| ADMIN_PASSWORD | admin123 | 管理员密码 |
| JWT_SECRET | (内置默认值) | JWT 签名密钥(请务必在生产环境修改) |
| FEISHU_WEBHOOK_URL | - | 飞书机器人 Webhook 地址(用于证书到期通知) |
| SMTP_HOST | - | SMTP 服务器地址(用于邮件通知) |
| SMTP_PORT | - | SMTP 端口 |
| SMTP_USER | - | SMTP 用户名 |
| SMTP_PASSWORD | - | SMTP 密码 |
| SMTP_FROM | - | 发件人地址 |
| NOTIFY_TO | - | 收件人邮箱(多个用逗号分隔) |
## API 接口
| 方法 | 路径 | 说明 | 需要认证 |
|------|------|------|---------|
| GET | /api/health | 健康检查 | 否 |
| POST | /api/login | 用户登录 | 否 |
| GET | /api/stats | 统计信息 | 是 |
| GET | /api/certificates | 证书列表 | 是 |
| GET | /api/certificates/:id | 证书详情 | 是 |
| POST | /api/certificates | 申请证书 | 是 |
| PUT | /api/certificates/:id | 更新证书配置 | 是 |
| DELETE | /api/certificates/:id | 删除证书 | 是 |
| POST | /api/certificates/:id/renew | 手动续期 | 是 |
| GET | /api/certificates/:id/files | 查看证书文件 | 是 |
| GET | /api/renewals/check | 触发续期检查 | 是 |
## 证书到期通知
系统支持两种通知方式:
### 飞书机器人
1. 在飞书群中添加 Webhook 机器人
2. 设置环境变量 `FEISHU_WEBHOOK_URL=https://open.feishu.cn/open-apis/bot/v2/hook/xxxxx`
### 邮件通知
设置 SMTP 相关环境变量:
```
SMTP_HOST=smtp.example.com
SMTP_PORT=587
SMTP_USER=user@example.com
SMTP_PASSWORD=your-password
SMTP_FROM=autossl@example.com
NOTIFY_TO=admin@example.com,ops@example.com
```
通知将在每天早上 8:00 自动检查并发送。30 天内到期的证书会触发通知。
## 证书文件位置
申请成功后的证书文件存储在 `./data/certs/<domain>/` 目录:
- `fullchain.pem` - 完整证书链
- `privkey.pem` - 私钥
- `chain.pem` - CA 证书链