Skip to content

Commit cfbc6be

Browse files
committed
update
1 parent aa61ad5 commit cfbc6be

File tree

4 files changed

+173
-26
lines changed

4 files changed

+173
-26
lines changed

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
# cloudflare-docker-proxy
22

3-
![deploy](https://github.com/ciiiii/cloudflare-docker-proxy/actions/workflows/deploy.yaml/badge.svg)
3+
![deploy](https://github.com/lightless233/cloudflare-docker-proxy/actions/workflows/deploy.yaml/badge.svg)
44

5-
[![Deploy to Cloudflare Workers](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/ciiiii/cloudflare-docker-proxy)
5+
[![Deploy to Cloudflare Workers](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/lightless233/cloudflare-docker-proxy)
66

7-
> If you're looking for proxy for helm, maybe you can try [cloudflare-helm-proxy](https://github.com/ciiiii/cloudflare-helm-proxy).
7+
> If you're looking for proxy for helm, maybe you can try [cloudflare-helm-proxy](https://github.com/lightless233/cloudflare-helm-proxy).
88
99
## Deploy
1010

1111
1. click the "Deploy With Workers" button
1212
2. follow the instructions to fork and deploy
1313
3. update routes as you requirement
1414

15-
[![Deploy to Cloudflare Workers](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/ciiiii/cloudflare-docker-proxy)
15+
[![Deploy to Cloudflare Workers](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/lightless233/cloudflare-docker-proxy)
1616

1717
## Routes configuration tutorial
1818

@@ -30,11 +30,11 @@
3030
- add more records and modify the config as you need
3131
```javascript
3232
const routes = {
33-
"docker.libcuda.so": "https://registry-1.docker.io",
34-
"quay.libcuda.so": "https://quay.io",
35-
"gcr.libcuda.so": "https://k8s.gcr.io",
36-
"k8s-gcr.libcuda.so": "https://k8s.gcr.io",
37-
"ghcr.libcuda.so": "https://ghcr.io",
33+
"docker.2222256.xyz": "https://registry-1.docker.io",
34+
"quay.2222256.xyz": "https://quay.io",
35+
"gcr.2222256.xyz": "https://k8s.gcr.io",
36+
"k8s-gcr.2222256.xyz": "https://k8s.gcr.io",
37+
"ghcr.2222256.xyz": "https://ghcr.io",
3838
};
3939
```
4040

src/help.html

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
<!DOCTYPE html>
2+
<html lang="zh-CN">
3+
<head>
4+
<meta charset="utf-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1">
6+
<title>镜像使用说明</title>
7+
<style>
8+
body {
9+
font-family: 'Roboto', sans-serif;
10+
margin: 0;
11+
padding: 0;
12+
background-color: #f4f4f4;
13+
}
14+
.header {
15+
background: linear-gradient(135deg, #667eea, #764ba2);
16+
color: #fff;
17+
padding: 20px 0;
18+
text-align: center;
19+
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
20+
position: relative;
21+
}
22+
.github-link {
23+
position: absolute;
24+
top: 10px;
25+
right: 20px;
26+
color: #fff;
27+
text-decoration: none;
28+
}
29+
.github-icon {
30+
width: 24px;
31+
height: 24px;
32+
vertical-align: middle;
33+
}
34+
.container {
35+
max-width: 800px;
36+
margin: 40px auto;
37+
padding: 20px;
38+
background-color: #fff;
39+
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
40+
border-radius: 10px;
41+
}
42+
.content {
43+
margin-bottom: 20px;
44+
}
45+
.footer {
46+
text-align: center;
47+
padding: 20px 0;
48+
background-color: #333;
49+
color: #fff;
50+
}
51+
pre {
52+
background-color: #272822;
53+
color: #f8f8f2;
54+
padding: 15px;
55+
border-radius: 5px;
56+
overflow-x: auto;
57+
}
58+
code {
59+
font-family: 'Source Code Pro', monospace;
60+
}
61+
a {
62+
color: #4CAF50;
63+
text-decoration: none;
64+
}
65+
a:hover {
66+
text-decoration: underline;
67+
}
68+
@media (max-width: 600px) {
69+
.container {
70+
margin: 20px;
71+
padding: 15px;
72+
}
73+
.header {
74+
padding: 15px 0;
75+
}
76+
}
77+
</style>
78+
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&family=Source+Code+Pro:wght@400;700&display=swap" rel="stylesheet">
79+
</head>
80+
<body>
81+
<div class="header">
82+
<h1>镜像使用说明</h1>
83+
</div>
84+
<div class="container">
85+
<div class="content">
86+
<p>为了加速 Docker 镜像拉取,你可以使用以下命令设置 registry mirror:</p>
87+
<pre><code id="registry-config">sudo tee /etc/docker/daemon.json &lt;&lt;EOF
88+
{
89+
"registry-mirrors": ["https://{{host}}"]
90+
}
91+
EOF
92+
# 配置完后需要重启 Docker 服务
93+
sudo systemctl restart docker
94+
</code></pre>
95+
<p>使用该代理从不同的镜像仓库拉取镜像,请参考以下命令:</p>
96+
<pre><code id="commands">
97+
# docker pull nginx:latest
98+
docker pull docker.{{host}}/library/nginx:latest # 拉取 Docker 官方镜像
99+
100+
# docker pull quay.io/coreos/etcd:latest
101+
docker pull quay.{{host}}/coreos/etcd:latest # 拉取 Quay 镜像
102+
103+
# docker pull gcr.io/google-containers/busybox:latest
104+
docker pull gcr.{{host}}/google-containers/busybox:latest # 拉取 GCR 镜像
105+
106+
# docker pull k8s.gcr.io/pause:latest
107+
docker pull k8s-gcr.{{host}}/pause:latest # 拉取 k8s.gcr.io 镜像
108+
109+
# docker pull registry.k8s.io/pause:latest
110+
docker pull k8s.{{host}}/pause:latest # 拉取 registry.k8s.io 镜像
111+
112+
# docker pull ghcr.io/github/super-linter:latest
113+
docker pull ghcr.{{host}}/github/super-linter:latest # 拉取 GitHub 容器镜像
114+
115+
# docker pull docker.cloudsmith.io/public/repo/image:latest
116+
docker pull cloudsmith.{{host}}/public/repo/image:latest # 拉取 Cloudsmith 镜像
117+
</code></pre>
118+
<p>为了避免 Worker 用量耗尽,你可以手动 pull 镜像然后 re-tag 之后 push 至本地镜像仓库。</p>
119+
</div>
120+
</div>
121+
<div class="footer">
122+
<p>Powered by Cloudflare Workers</p>
123+
</div>
124+
<script>
125+
document.addEventListener('DOMContentLoaded', function() {
126+
const host = window.location.hostname;
127+
const mainDomain = host.split('.').slice(-2).join('.');
128+
const registryConfigElement = document.getElementById('registry-config');
129+
const commandsElement = document.getElementById('commands');
130+
131+
registryConfigElement.innerHTML = registryConfigElement.innerHTML.replace(/{{host}}/g, host);
132+
commandsElement.innerHTML = commandsElement.innerHTML.replace(/{{host}}/g, mainDomain);
133+
});
134+
</script>
135+
</body>
136+
</html>

src/index.js

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import DOCS from "./help.html"
2+
13
addEventListener("fetch", (event) => {
24
event.passThroughOnException();
35
event.respondWith(handleRequest(event.request));
@@ -7,17 +9,17 @@ const dockerHub = "https://registry-1.docker.io";
79

810
const routes = {
911
// production
10-
"docker.libcuda.so": dockerHub,
11-
"quay.libcuda.so": "https://quay.io",
12-
"gcr.libcuda.so": "https://gcr.io",
13-
"k8s-gcr.libcuda.so": "https://k8s.gcr.io",
14-
"k8s.libcuda.so": "https://registry.k8s.io",
15-
"ghcr.libcuda.so": "https://ghcr.io",
16-
"cloudsmith.libcuda.so": "https://docker.cloudsmith.io",
17-
"ecr.libcuda.so": "https://public.ecr.aws",
12+
"docker.2222256.xyz": dockerHub,
13+
"quay.2222256.xyz": "https://quay.io",
14+
"gcr.2222256.xyz": "https://gcr.io",
15+
"k8s-gcr.2222256.xyz": "https://k8s.gcr.io",
16+
"k8s.2222256.xyz": "https://registry.k8s.io",
17+
"ghcr.2222256.xyz": "https://ghcr.io",
18+
"cloudsmith.2222256.xyz": "https://docker.cloudsmith.io",
19+
"ecr.2222256.xyz": "https://public.ecr.aws",
1820

1921
// staging
20-
"docker-staging.libcuda.so": dockerHub,
22+
"docker-staging.2222256.xyz": dockerHub,
2123
};
2224

2325
function routeByHosts(host) {
@@ -45,6 +47,15 @@ async function handleRequest(request) {
4547
}
4648
const isDockerHub = upstream == dockerHub;
4749
const authorization = request.headers.get("Authorization");
50+
if (url.pathname === "/") {
51+
return new Response(DOCS, {
52+
status: 200,
53+
headers: {
54+
"content-type": "text/html"
55+
}
56+
});
57+
}
58+
4859
if (url.pathname == "/v2/") {
4960
const newUrl = new URL(upstream + "/v2/");
5061
const headers = new Headers();

wrangler.toml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ TARGET_UPSTREAM = "https://registry-1.docker.io"
1313
[env.production]
1414
name = "cloudflare-docker-proxy"
1515
# routes = [
16-
# { pattern = "docker.libcuda.so", custom_domain = true },
17-
# { pattern = "quay.libcuda.so", custom_domain = true },
18-
# { pattern = "gcr.libcuda.so", custom_domain = true },
19-
# { pattern = "k8s-gcr.libcuda.so", custom_domain = true },
20-
# { pattern = "k8s.libcuda.so", custom_domain = true },
21-
# { pattern = "ghcr.libcuda.so", custom_domain = true },
22-
# { pattern = "cloudsmith.libcuda.so", custom_domain = true },
16+
# { pattern = "docker.2222256.xyz", custom_domain = true },
17+
# { pattern = "quay.2222256.xyz", custom_domain = true },
18+
# { pattern = "gcr.2222256.xyz", custom_domain = true },
19+
# { pattern = "k8s-gcr.2222256.xyz", custom_domain = true },
20+
# { pattern = "k8s.2222256.xyz", custom_domain = true },
21+
# { pattern = "ghcr.2222256.xyz", custom_domain = true },
22+
# { pattern = "cloudsmith.2222256.xyz", custom_domain = true },
2323
# ]
2424

2525
[env.production.vars]
@@ -28,7 +28,7 @@ TARGET_UPSTREAM = ""
2828

2929
[env.staging]
3030
name = "cloudflare-docker-proxy-staging"
31-
# route = { pattern = "docker-staging.libcuda.so", custom_domain = true }
31+
# route = { pattern = "docker-staging.2222256.xyz", custom_domain = true }
3232

3333
[env.staging.vars]
3434
MODE = "staging"

0 commit comments

Comments
 (0)