这是一个由两个 Cloudflare Workers 组成的 GitHub 反向代理项目:
github.com/worker.js:代理github.com、*.github.com和 GitHub 页面资源。githubusercontent.com/worker.js:代理githubusercontent.com及其子域资源。
也可以直接使用已经部署的 6GitHub。
https://github.com/<URL PATH>
→ https://6github.com/<URL PATH>
https://raw.githubusercontent.com/<URL PATH>
→ https://raw.6githubusercontent.com/<URL PATH>
GitHub 子域会保留原有子域名称:
https://api.github.com/<URL PATH>
→ https://api.6github.com/<URL PATH>
https://avatars.githubusercontent.com/<URL PATH>
→ https://avatars.6githubusercontent.com/<URL PATH>
可以把完整的 GitHub 或 GitHubusercontent URL 放在 https://6github.com/ 后面:
https://6github.com/https://github.com/Codfish789/github-proxy
返回 302:
https://6github.com/Codfish789/github-proxy
Raw 文件同样支持:
https://6github.com/https://raw.githubusercontent.com/<URL PATH>
返回 302:
https://raw.6githubusercontent.com/<URL PATH>
该入口只在主域名 6github.com 生效,并且只接受以下目标:
github.com和*.github.comgithubusercontent.com和*.githubusercontent.com
其他网站不会触发完整 URL 重定向,以避免形成开放重定向。Path 和查询参数会被保留。
大部分域名映射属于 Worker 内部反向代理,不会向浏览器返回额外的 302。
| 镜像域名 | GitHub 源站 |
|---|---|
6github.com |
github.com |
<SUBDOMAIN>.6github.com |
<SUBDOMAIN>.github.com |
6githubusercontent.com |
githubusercontent.com |
<SUBDOMAIN>.6githubusercontent.com |
<SUBDOMAIN>.githubusercontent.com |
ghassets.6github.com |
githubassets.com |
<PREFIX>-ghassets.6github.com |
<PREFIX>.githubassets.com |
所有回源请求强制使用 HTTPS,并保留原请求的 Path 和查询参数。
以下请求会返回 302 到 https://help.6github.com/:
- Path 严格等于
/ - Path 中包含
/login - Path 中包含
/signup - Path 中包含
/copilot - 目标源站为
user-images.githubusercontent.com
Path 关键字匹配不区分大小写。
当前项目不代理这个域名。以下两种访问方式最终都会跳转到帮助页:
https://user-images.6githubusercontent.com/<URL PATH>
https://6github.com/https://user-images.githubusercontent.com/<URL PATH>
第二种方式会先跳转到 user-images.6githubusercontent.com,随后由资源 Worker 跳转到帮助页。
raw.githubusercontent.com、avatars.githubusercontent.com 等其他资源子域不受这条规则影响。
主站 Worker 会:
- 将镜像域名映射回对应 GitHub 源站。
- 将请求的
Host、Origin和Referer改回源站域名。 - 手动处理源站
Location,使后续重定向继续使用镜像域名。 - 修改文本响应中的
github.com、githubusercontent.com和githubassets.com链接。 - 为镜像域名补充 CSP 和 CORS 规则。
- 对二进制响应、
206 Partial Content和带Content-Range的响应进行流式透传,不修改正文。
资源 Worker 默认不修改响应正文,以保留 gzip/br 压缩和流式传输,只重写 Location 并删除 CSP 响应头。
其他结果:
- 不允许的 Host 返回
403 Forbidden Host。 - GitHub 上游请求失败返回
502 Upstream request failed。 - WebSocket
101响应原样透传。
- 一个接入 Cloudflare 的域名
- 一个 Cloudflare 账户
- 两个 Workers
部署前修改两个 worker.js 顶部配置区中的源站域名、镜像域名和帮助页地址,并确保两个文件的配置保持一致。
需要为两个 Worker 分别配置主域和通配符子域路由:
6github.com/*
*.6github.com/*
6githubusercontent.com/*
*.6githubusercontent.com/*
如果使用自己的域名,请将上述域名替换为你在 Worker 配置区填写的镜像域名。
DNS 可按实际部署方案指向 Cloudflare 或优选入口:
| 域名 | DNS 记录值 |
|---|---|
yourdomain.com |
Cloudflare 或所选优选入口 |
*.yourdomain.com |
Cloudflare 或所选优选入口 |
详细部署过程可参考作者博客。
项目使用 Node.js 内置测试工具,不需要安装第三方测试依赖:
npm test测试覆盖完整 URL 重定向、主站和资源域映射、响应正文与 Location 重写、CORS/CSP、分段响应、资源流式透传和上游异常处理。
该项目仅建议用于公开代码浏览和静态资源下载。不要通过公共镜像登录、注册或提交账号、密码、Token 及其他敏感信息。