tianrking/EdgeMirror

GitHub: tianrking/EdgeMirror

EdgeMirror 是一个部署在边缘无服务器平台上的单域名加速网关,通过路径路由统一代理和加速 PyPI、Docker、Hugging Face 等各类开发者软件源。

Stars: 206 | Forks: 36

English | Español | 中文

EdgeMirror

一个用于开发者源的 CDN 风格边缘镜像网关。

在一个干净的域名背后加速 PyPI、PyTorch、Hugging Face、GitHub、Docker registries、Linux 镜像、npm、Go modules、Maven、crates.io、runtime 下载以及通用文件转发。

Deploy to Cloudflare Deploy with Vercel

Verify Runtime Language Package manager Maintainer

## 为什么选择 EdgeMirror EdgeMirror 是一个用于常见开发者源的单域名边缘镜像网关。推荐的生产环境模式是使用一个公共域名,例如 `edgemirror.w0x7ce.eu`,并通过路径暴露每个源加速器:`/edgemirror`、`/pypi`、`/hf`、`/github`、`/docker`、`/mirrors`、`/proxy`、`/npm`、`/go`、`/maven`、`/crates`、`/downloads` 和 `/help`。 每个页面都包含一个共享的语言切换器,支持英语、西班牙语和中文。工具名称保持为英文,而解释、使用说明和常见 UI 标签会跟随所选的语言。 维护者:[tianrking](https://github.com/tianrking) 关键词:边缘镜像网关、CDN 风格源加速、Cloudflare Workers 代理、Vercel Functions 代理、PyPI 镜像加速器、PyTorch wheel 代理、Hugging Face 镜像、Docker registry 代理、GitHub raw 代理、Linux 镜像代理、npm registry 代理、Go module 代理、Maven 代理、Gradle 镜像、crates.io sparse registry 代理、runtime 下载加速器。 ## 工具栈

Cloudflare Workers Vercel Functions JavaScript ESM Single domain Path routing PyPI PyTorch Hugging Face GitHub Docker Linux mirrors Universal proxy npm Go modules Maven crates.io Downloads Syntax check Smoke test npm audit One click deploy Wrangler

## 服务矩阵 `Stable` 表示该路由推荐用于日常使用。`Test` 表示加速器已实现、已接入冒烟测试,并准备好在升级为 stable 之前进行验证。 | 状态 | 服务 | 单域名路由 | 加速内容 | | --- | --- | --- | --- | | Stable | EdgeMirror Portal | `/` 或 `/edgemirror` | 每个源加速器的可视化仪表板和使用代码片段 | | Stable | Help | `/help` | 英语、西班牙语和中文的路由映射、Web 使用说明、CLI 方案和配置指南 | | Stable | PyPI / PyTorch | `/pypi` | PyPI simple 索引、包文件和 PyTorch wheel 下载 | | Stable | Hugging Face | `/hf` | Hugging Face API、模型文件、数据集和 LFS 下载 | | Stable | GitHub | `/github` | Git clone、raw 文件、release assets 和 GitHub pages | | Stable | Docker Registry | `/docker` UI, `/v2` API | Docker Hub 以及 `quay`、`gcr`、`k8s`、`ghcr`、`nvcr` 前缀 | | Stable | Linux Mirrors | `/mirrors` | APT、YUM、DNF、Pacman、wget 和 curl 镜像路径 | | Stable | Universal Proxy | `/proxy` | 带有文件名处理的任意 HTTP/HTTPS 文件 URL | | Test | npm Registry | `/npm` | npm、pnpm、yarn 元数据和 tarball 下载 | | Test | Go Module Proxy | `/go` | GOPROXY module 列表、版本元数据、`.mod` 和 `.zip` 文件 | | Test | Maven / Gradle | `/maven` | Maven Central、Google Maven、Gradle Plugin Portal 和 JitPack | | Test | crates.io Sparse | `/crates` | Cargo sparse 索引和 `.crate` 包下载 | | Test | Runtime Downloads | `/downloads` | Node.js、Python、Go、Rustup、Open VSX、SourceForge、GitLab、Gitea 和直接文件 URL | ## 一键部署 ### 部署到 Cloudflare Workers 点击本 README 顶部的 Cloudflare 按钮,或打开: ``` https://deploy.workers.cloudflare.com/?url=https://github.com/tianrking/edgemirror ``` Cloudflare 会读取 `wrangler.toml`,创建 Worker,并将其部署到账户提供的 Worker 名称。默认配置特意设计为便携式:它启用 `workers.dev`,禁用预览 URL,并且不绑定维护者的自定义域名。 Worker 部署完成后,在 Cloudflare 仪表板中添加一个自定义域名,或者在确认该域名属于您的 Cloudflare 账户后,将 `wrangler.custom-domain.example.toml` 中的路由块复制到 `wrangler.toml` 中。在该域名上,每个工具仍将使用相同的路径模型。 ### 部署到 Vercel 点击本 README 顶部的 Vercel 按钮,或打开: ``` https://vercel.com/new/clone?repository-url=https://github.com/tianrking/edgemirror ``` Vercel 使用 `api/index.js` 作为 Web Handler 函数,并使用 `vercel.json` 将每个路径路由到该函数。Vercel 部署使用相同的路径模型:`/edgemirror`、`/pypi`、`/hf`、`/github`、`/docker`、`/mirrors`、`/proxy`、`/npm`、`/go`、`/maven`、`/crates`、`/downloads` 和 `/help`。Docker Registry API 流量也会在 `/v2`、`/token` 和 `/_worker_blob_proxy` 处被自动检测,因此单个 Vercel 域名可以在镜像名称中不包含 `/docker` 前缀的情况下处理 Docker 拉取。 ## 本地开发 ``` npm install npm run verify npm run dev ``` 实用脚本: | 命令 | 用途 | | --- | --- | | `npm run dev` | 启动 Cloudflare Worker 开发服务器 | | `npm run dev:cloudflare` | 同 `npm run dev` | | `npm run dev:vercel` | 使用 `npx vercel@latest dev` 启动 Vercel 本地开发 | | `npm run check` | 对 `src` 和 `scripts` 下的每个 JavaScript 文件进行语法检查 | | `npm run smoke:vercel` | 导入 Vercel 函数入口并验证核心路由 | | `npm run verify` | 运行语法检查、Vercel 冒烟测试和高危 npm audit | | `npm run deploy:cloudflare` | 使用 Wrangler 部署 | | `npm run deploy:vercel` | 使用 `npx vercel@latest --prod` 部署到 Vercel 生产环境 | ## 路由模型 EdgeMirror 基于单域名路径路由设计: | Runtime 风格 | 示例 | 说明 | | --- | --- | --- | | 路径路由 | `https://edgemirror.w0x7ce.eu/pypi/simple/` | 推荐的生产环境模型 | | Vercel 路径路由 | `https://your-app.vercel.app/pypi/simple/` | 一键 Vercel 部署后的相同路由 | 对于单域名部署上的 Docker,请直接使用部署主机: ``` docker pull your-app.vercel.app/library/nginx:latest ``` 路由器会自动将 Docker 的 `/v2`、`/token` 和 blob 重定向流量转发给 Docker 工具。 健康检查位于: ``` /health /healthz /__health ``` 它们会返回包含项目版本和已注册服务列表的 JSON。 ## 示例 安装 Python 包: ``` pip install numpy -i https://edgemirror.w0x7ce.eu/pypi/simple/ ``` 安装 PyTorch wheel: ``` pip install torch torchvision --index-url https://edgemirror.w0x7ce.eu/pypi/pytorch/cu118 ``` 下载 Hugging Face 模型: ``` export HF_ENDPOINT=https://edgemirror.w0x7ce.eu/hf huggingface-cli download gpt2 ``` 通过 GitHub 代理进行 clone: ``` git clone https://edgemirror.w0x7ce.eu/github/vercel/next.js.git ``` 拉取 Docker 镜像: ``` docker pull edgemirror.w0x7ce.eu/library/nginx:latest ``` 代理通用文件: ``` curl -L -O "https://edgemirror.w0x7ce.eu/proxy/https://nodejs.org/dist/v22.11.0/node-v22.11.0-x64.msi" ``` 使用全新的 test npm registry 路由: ``` npm install lodash --registry=https://edgemirror.w0x7ce.eu/npm/ pnpm install lodash --registry=https://edgemirror.w0x7ce.eu/npm/ ``` 使用全新的 test Go module 路由: ``` go env -w GOPROXY=https://edgemirror.w0x7ce.eu/go,direct ``` 使用全新的 test Maven / Gradle 路由: ``` repositories { maven { url = uri("https://edgemirror.w0x7ce.eu/maven/maven-central") } maven { url = uri("https://edgemirror.w0x7ce.eu/maven/google") } maven { url = uri("https://edgemirror.w0x7ce.eu/maven/gradle-plugin") } } ``` 使用全新的 test crates.io sparse 路由: ``` [source.crates-io] replace-with = "edgemirror" [source.edgemirror] registry = "sparse+https://edgemirror.w0x7ce.eu/crates/" ``` 使用全新的 test runtime 下载路由: ``` curl -L -O "https://edgemirror.w0x7ce.eu/downloads/node/v22.11.0/node-v22.11.0-x64.msi" curl -L -O "https://edgemirror.w0x7ce.eu/downloads/https://nodejs.org/dist/v22.11.0/node-v22.11.0-x64.msi" ``` ## 项目布局 ``` api/index.js Vercel Functions Web Handler entry scripts/check-syntax.mjs Cross-platform JavaScript syntax checker scripts/smoke-vercel.mjs Vercel runtime smoke test src/config.js Project metadata, service registry, health paths src/html.js HTML rewrite fallback for non-Cloudflare runtimes src/i18n.js Language detection, language switch links, and localized URLs src/index.js Host/path router and health endpoint src/proxy-utils.js Shared CORS, redirect, header, and proxy helpers src/tools/*.js Individual tool implementations vercel.json Vercel routing and build configuration wrangler.toml Portable Cloudflare Workers deploy configuration wrangler.custom-domain.example.toml Optional custom-domain configuration example ``` ## 配置 在添加、重命名或记录工具时,请编辑 `src/config.js`。在更改 Cloudflare Worker 名称或兼容性日期时,请编辑 `wrangler.toml`。 对于 Cloudflare 自定义域名,请在 Cloudflare 仪表板中添加域名,或者在目标账户中可用该域名后,使用 `wrangler.custom-domain.example.toml` 作为参考。对于 Vercel 自定义域名,请在 Vercel 仪表板中添加一个主域名,并保持相同的路径路由。 ## 生产环境说明 - 部署前请确保 `npm run verify` 通过。 - 保持 `wrangler` 更新;它是本地的 Cloudflare 开发/部署工具链。 - Cloudflare 自定义域名是特定于账户的,因此便携式默认的 `wrangler.toml` 没有对其进行硬编码。 - 为公共产品体验使用一个主域名;传统的每个工具单独的主机名不是推荐的交互模型。 - 某些上游服务可能具有速率限制、身份验证要求或服务条款,这些在通过代理时仍然适用。 ## 路线图 - 在进行更多上游兼容性检查后,将 test 加速器提升为 stable。 - 通过环境变量添加可配置的服务域名。 - 添加结构化访问日志和可选的请求追踪。 - 使用模拟的上游响应添加针对每个工具的冒烟测试。 - 为 portal 和工具页面添加部署预览截图。
标签:CDN网关, SOC Prime, 开发工具, 暗色界面, 程序员工具, 网络加速, 自定义脚本, 边缘计算, 镜像站, 高对比度