forked from GitHub/cloudflare-docker-proxy
Compare commits
5 Commits
master
...
8cf519fc3e
| Author | SHA1 | Date | |
|---|---|---|---|
| 8cf519fc3e | |||
| 5a29e9a6ea | |||
| 533e46e0dc | |||
| 0dc7dbd355 | |||
| 9bb87fe8ef |
25
.github/workflows/stage.yaml
vendored
Normal file
25
.github/workflows/stage.yaml
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
name: Deploy to Cloudflare Workers(Staging)
|
||||
|
||||
on:
|
||||
pull_request_target:
|
||||
paths-ignore:
|
||||
- '**.md'
|
||||
repository_dispatch:
|
||||
|
||||
jobs:
|
||||
build-and-deploy:
|
||||
runs-on: ubuntu-latest
|
||||
name: Build & Deploy
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Publish
|
||||
uses: cloudflare/wrangler-action@v3
|
||||
env:
|
||||
CUSTOM_DOMAIN: ${{ secrets.CUSTOM_DOMAIN || 'libcuda.so' }}
|
||||
with:
|
||||
apiToken: ${{ secrets.CF_API_TOKEN }}
|
||||
accountId: ${{secrets.CF_ACCOUNT_ID}}
|
||||
vars:
|
||||
CUSTOM_DOMAIN
|
||||
command: deploy --env staging --minify src/index.js
|
||||
environment: staging
|
||||
@@ -1 +0,0 @@
|
||||
nodeLinker: node-modules
|
||||
13
README.md
13
README.md
@@ -1,17 +1,8 @@
|
||||
# cloudflare-docker-proxy
|
||||
|
||||
> ### ⚠️ **Important Notice**
|
||||
> <span style="color:#d73a49;font-weight:bold">Docker Hub is rate-limiting Cloudflare Worker IPs, causing frequent <code>429</code> errors.</span>
|
||||
> <span style="color:#d73a49;font-weight:bold">This project is currently NOT recommended for production use.</span>
|
||||
|
||||
|
||||
Due to the current instability, this project is not recommended for production use.
|
||||
We will provide updates as soon as more information becomes available.
|
||||
|
||||
|
||||

|
||||
|
||||
[](https://deploy.workers.cloudflare.com/?url=https://github.com/ciiiii/cloudflare-docker-proxy)
|
||||
[](https://deploy.workers.cloudflare.com/?url=https://git.yinr.cc/Yinr/cloudflare-docker-proxy.git)
|
||||
|
||||
> If you're looking for proxy for helm, maybe you can try [cloudflare-helm-proxy](https://github.com/ciiiii/cloudflare-helm-proxy).
|
||||
|
||||
@@ -21,7 +12,7 @@ We will provide updates as soon as more information becomes available.
|
||||
2. follow the instructions to fork and deploy
|
||||
3. update routes as you requirement
|
||||
|
||||
[](https://deploy.workers.cloudflare.com/?url=https://github.com/ciiiii/cloudflare-docker-proxy)
|
||||
[](https://deploy.workers.cloudflare.com/?url=https://git.yinr.cc/Yinr/cloudflare-docker-proxy.git)
|
||||
|
||||
## Routes configuration tutorial
|
||||
|
||||
|
||||
3023
package-lock.json
generated
3023
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -4,18 +4,18 @@
|
||||
"description": "",
|
||||
"version": "1.0.0",
|
||||
"author": "ciiiii <allen.cccccnm@gmail.com>",
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"prettier": "^2.4.1",
|
||||
"webpack": "^5.65.0",
|
||||
"webpack-cli": "^4.9.1",
|
||||
"wrangler": "^4.82.2"
|
||||
"wrangler": "^3.36.0"
|
||||
},
|
||||
"scripts": {
|
||||
"format": "prettier --write '**/*.{js,css,json,md}'",
|
||||
"build": "webpack",
|
||||
"dev": "npx wrangler dev src/index.js --env dev"
|
||||
"dev": "wrangler dev src/index.js --env dev"
|
||||
},
|
||||
"license": "MIT",
|
||||
"main": "src/index.js",
|
||||
"packageManager": "yarn@4.3.0+sha512.1606bef7c84bc7d83b8576063de2fd08f7d69f9939015bed800f9585a002390268ecc777e9feeba7e26e9556aef6beaad4806968db2182ab5dd3e955ab3b9a0b"
|
||||
"main": "src/index.js"
|
||||
}
|
||||
|
||||
17
src/index.js
17
src/index.js
@@ -32,9 +32,6 @@ function routeByHosts(host) {
|
||||
|
||||
async function handleRequest(request) {
|
||||
const url = new URL(request.url);
|
||||
if (url.pathname == "/") {
|
||||
return Response.redirect(url.protocol + "//" + url.host + "/v2/", 301);
|
||||
}
|
||||
const upstream = routeByHosts(url.hostname);
|
||||
if (upstream === "") {
|
||||
return new Response(
|
||||
@@ -108,22 +105,12 @@ async function handleRequest(request) {
|
||||
const newReq = new Request(newUrl, {
|
||||
method: request.method,
|
||||
headers: request.headers,
|
||||
// don't follow redirect to dockerhub blob upstream
|
||||
redirect: isDockerHub ? "manual" : "follow",
|
||||
redirect: "follow",
|
||||
});
|
||||
const resp = await fetch(newReq);
|
||||
if (resp.status == 401) {
|
||||
return responseUnauthorized(url);
|
||||
}
|
||||
// handle dockerhub blob redirect manually
|
||||
if (isDockerHub && resp.status == 307) {
|
||||
const location = new URL(resp.headers.get("Location"));
|
||||
const redirectResp = await fetch(location.toString(), {
|
||||
method: "GET",
|
||||
redirect: "follow",
|
||||
});
|
||||
return redirectResp;
|
||||
}
|
||||
return resp;
|
||||
}
|
||||
|
||||
@@ -157,7 +144,7 @@ async function fetchToken(wwwAuthenticate, scope, authorization) {
|
||||
}
|
||||
|
||||
function responseUnauthorized(url) {
|
||||
const headers = new Headers();
|
||||
const headers = new(Headers);
|
||||
if (MODE == "debug") {
|
||||
headers.set(
|
||||
"Www-Authenticate",
|
||||
|
||||
@@ -1,37 +1,24 @@
|
||||
name = "cloudflare-docker-proxy"
|
||||
compatibility_date = "2023-12-01"
|
||||
main = "src/index.js"
|
||||
|
||||
[vars]
|
||||
MODE = "production"
|
||||
TARGET_UPSTREAM = ""
|
||||
CUSTOM_DOMAIN = "example.com"
|
||||
|
||||
[dev]
|
||||
ip = "0.0.0.0"
|
||||
port = 8787
|
||||
local_protocol = "http"
|
||||
|
||||
[env.vars]
|
||||
CUSTOM_DOMAIN = "lolicon.in"
|
||||
|
||||
[env.dev.vars]
|
||||
MODE = "debug"
|
||||
TARGET_UPSTREAM = "https://registry-1.docker.io"
|
||||
|
||||
[env.production]
|
||||
name = "cloudflare-docker-proxy"
|
||||
# routes = [
|
||||
# { pattern = "docker.libcuda.so", custom_domain = true },
|
||||
# { pattern = "quay.libcuda.so", custom_domain = true },
|
||||
# { pattern = "gcr.libcuda.so", custom_domain = true },
|
||||
# { pattern = "k8s-gcr.libcuda.so", custom_domain = true },
|
||||
# { pattern = "k8s.libcuda.so", custom_domain = true },
|
||||
# { pattern = "ghcr.libcuda.so", custom_domain = true },
|
||||
# { pattern = "cloudsmith.libcuda.so", custom_domain = true },
|
||||
# ]
|
||||
|
||||
[env.production.vars]
|
||||
MODE = "production"
|
||||
TARGET_UPSTREAM = ""
|
||||
CUSTOM_DOMAIN = "example.com"
|
||||
|
||||
[env.staging]
|
||||
name = "cloudflare-docker-proxy-staging"
|
||||
@@ -40,4 +27,3 @@ name = "cloudflare-docker-proxy-staging"
|
||||
[env.staging.vars]
|
||||
MODE = "staging"
|
||||
TARGET_UPSTREAM = ""
|
||||
CUSTOM_DOMAIN = "example.com"
|
||||
|
||||
Reference in New Issue
Block a user