类似 jsDelivr 的静态资源 CDN 加速服务,支持多源站代理和国内合规管理。
当前版本: v1.9.0 (Frontend: 1.9.0+fe21a1d2.20260202, Backend: 1.9.8+fe21a1d2.20260202)
用户 → EdgeOne (WAF+缓存+日志) → [缓存HIT] → 直接返回 ↓ [缓存MISS] → Go回源服务 → 白名单校验 → 302重定向 → 源站 ↓ HTTP日志投递 → /api/logs/edgeone → PostgreSQL(90天) → >90天gzip归档
| 层级 | 技术 |
|---|---|
| CDN/边缘层 | 腾讯云 EdgeOne |
| 后端服务 | Go + Gin |
| 数据库 | PostgreSQL 18+ |
| 缓存 | Redis 7+ |
| 前端管理台 | Vue3 + Element Plus |
# 拉取或构建镜像
docker pull edgeone-static:1.9.0-pgrs
# 一键启动(包含数据库和缓存)
docker run -d \
--name edgeone-static \
-p 8080:8080 \
-p 5432:5432 \
-p 6379:6379 \
edgeone-static:1.9.0-pgrs
# 访问服务
# 主页: http://localhost:8080
# 管理后台: http://localhost:8080/admin
# 默认账号: admin / admin123
# 启动 PostgreSQL 和 Redis
docker run -d --name postgres -p 5432:5432 -e POSTGRES_USER=cdn_user -e POSTGRES_PASSWORD=cdn_pass -e POSTGRES_DB=cdn_service postgres:16
docker run -d --name redis -p 6379:6379 redis:7
# 启动应用
docker run -d \
--name edgeone-static \
-p 8080:8080 \
-e DB_HOST=host.docker.internal \
-e DB_PORT=5432 \
-e DB_USER=cdn_user \
-e DB_PASSWORD=cdn_pass \
-e DB_NAME=cdn_service \
-e REDIS_HOST=host.docker.internal \
-e REDIS_PORT=6379 \
edgeone-static:1.9.0
cd backend
# 安装依赖
go mod download
# 配置环境变量
export DB_HOST=localhost
export DB_PORT=5432
export DB_NAME=cdn_service
export DB_USER=cdn_user
export DB_PASSWORD=secret
export REDIS_HOST=localhost
export REDIS_PORT=6379
export JWT_SECRET=your-jwt-secret
# 启动服务(自动初始化数据库)
go run cmd/server/main.go
服务默认运行在 :8080 端口。
项目已融合主页和管理后台,统一在 frontend/admin 目录下:
cd frontend/admin
# 安装依赖
npm install
# 开发模式
npm run dev
# 生产构建
npm run build
访问地址:
默认管理员账号:
adminadmin123| 前缀 | 源站 | 示例 |
|---|---|---|
/gh/ | GitHub Raw | /gh/user/repo/file.js → https://raw.githubusercontent.com/user/repo/file.js |
/npm/ | unpkg/jsDelivr | /npm/package@version/file.js → https://unpkg.com/package@version/file.js |
/cdnjs/ | cdnjs | /cdnjs/library/version/file.js → https://cdnjs.cloudflare.com/ajax/libs/library/version/file.js |
/google/ | Google Hosted | /google/library/file.js → https://ajax.googleapis.com/ajax/libs/library/file.js |
/bootcdn/ | BootCDN | /bootcdn/library/file.js → https://cdn.bootcdn.net/ajax/libs/library/file.js |
/cnb/ | cnb.cool | /cnb/project/file.js → https://cnb.cool/project/file.js |
/staticfile/ | StaticFile | /staticfile/library/file.js → https://cdn.staticfile.org/library/file.js |
在管理后台的 "CDN 源站管理" 页面,可以动态添加新的源站:
http://localhost:8080/admin/cdn-sourcesjsdelivr)/jsdelivr/)https://cdn.jsdelivr.net/npm)cdn.jsdelivr.net)示例: 添加 jsdelivr 源站后
curl -I http://localhost:8080/jsdelivr/vue@3/dist/vue.global.js
# HTTP/1.1 302 Found
# Location: https://cdn.jsdelivr.net/npm/vue@3/dist/vue.global.js
# 查看完整版本信息
./scripts/gen-version.sh all
# 输出示例:
# ================================
# 📦 EdgeOne Static 版本信息
# ================================
# Frontend: 1.9.0+fe21a1d2.20260202
# Backend: 1.9.8+fe21a1d2.20260202
# Docker Tag: 1.9.0
# Git Hash: fe21a1d2
# Build Date: 20260202
# ================================
# 更新所有 package.json 和后端版本文件
./scripts/update-version.sh
1.9.0+{git_hash}.{build_date}1.9.8+{git_hash}.{build_date}1.9.0database:
host: localhost
port: 5432
name: cdn_service
user: cdn_user
password: your_password
max_connections: 20
edgeone:
zone_id: your_zone_id
secret_id: your_secret_id
secret_key: your_secret_key
在管理后台的"站点管理"中配置:
# 构建基础镜像(无环境)
make docker-build-minimal
# 构建完整镜像(含 PostgreSQL + Redis)
make docker-build-full
# 构建所有镜像
make docker-build
# 查看版本信息
make version
# 运行基础镜像(需外部数据库)
make docker-run-minimal
# 运行完整镜像(自带数据库)
make docker-run-full
# 停止并清理容器
make docker-clean
/workspace/ ├── README.md # 项目说明文档 ├── ProjectStructurePlan.md # 项目架构规划 ├── version.json # 版本配置文件 ├── Dockerfile # Docker 基础镜像构建 ├── Dockerfile.full # Docker 完整镜像构建(含数据库) ├── Makefile # 常用命令脚本 ├── DevelopmentOperations/ # 对话操作记录目录 │ ├── backend/ # Go 后端服务 │ ├── cmd/server/main.go # 主服务入口 │ ├── internal/ │ │ ├── handler/ # HTTP 处理器 │ │ ├── service/ # 业务逻辑层 │ │ ├── repository/ # 数据访问层 │ │ ├── middleware/ # 中间件 │ │ └── version/ # 版本信息 │ ├── configs/ # 配置文件 │ └── deployments/ # 部署配置 │ ├── frontend/admin/ # Vue3 管理后台(融合主页) │ ├── src/ │ │ ├── views/ # 页面视图 │ │ ├── api/ # API 接口 │ │ ├── components/ # 公共组件 │ │ └── router/ # 路由配置 │ └── package.json │ ├── docs/api/ # API 文档 └── scripts/ # 运维脚本 ├── gen-version.sh # 版本号生成工具 ├── update-version.sh # 一键更新版本 ├── docker-entrypoint.sh # Docker 容器启动脚本 └── supervisord.conf # 进程管理配置
| 指标 | 目标值 | 说明 |
|---|---|---|
| 302 重定向响应 | < 10ms | 白名单校验+URL解析 |
| 日志接收处理 | > 10000 条/秒 | 批量写入优化 |
| 数据库写入 | > 10000 条/天 | 单服务器轻松支撑 |
| 缓存命中率 | > 80% | EdgeOne 边缘缓存 |
| WAF 拦截响应 | < 1ms | 边缘实时拦截 |
MIT