前置要求
- 有一个自己的域名且托管至Cloudflare
部署
代码
https://github.com/ciiiii/cloudflare-docker-proxy
具体操作主要参考这个项目,首先克隆项目至本地。
假设有自己的域名: mydomain.com,根据实际情况替换为自己的域名。
修改 src/index.js
const routes = {
"docker.mydomain.com": "https://registry-1.docker.io",
"quay.mydomain.com": "https://quay.io",
"gcr.mydomain.com": "https://gcr.io",
"k8s-gcr.mydomain.com": "https://k8s.gcr.io",
"k8s.mydomain.com": "https://registry.k8s.io",
"ghcr.mydomain.com": "https://ghcr.io",
"cloudsmith.mydomain.com": "https://docker.cloudsmith.io",
};
修改 wrangler.toml
,自动将Worker绑定至自己的域名,并自动添加SSL证书
name = "cloudflare-docker-proxy"
workers_dev = true
main = "src/index.js"
compatibility_date = "2021-12-07"
+ routes = [
+ { pattern = "docker.mydomain.com", custom_domain = true },
+ { pattern = "quay.mydomain.com", custom_domain = true },
+ { pattern = "gcr.mydomain.com", custom_domain = true },
+ { pattern = "k8s-gcr.mydomain.com", custom_domain = true },
+ { pattern = "k8s.mydomain.com", custom_domain = true },
+ { pattern = "ghcr.mydomain.com", custom_domain = true },
+ { pattern = "cloudsmith.mydomain.com", custom_domain = true },
+ ]
部署
wrangler的安装和使用参考:GitHub - zgimszhd61/cloudflare-quickstart
输入命令,起飞~
wrangler deploy
使用
- docker pull busybox:stable
+ docker.mydomain.com/library/busybox:stable
- docker pull ginuerzh/gost:latest
+ docker.mydomain.com/ginuerzh/gost:latest
修改Docker Mirror的方式
经过佬的验证可用