forked from GitHub/cloudflare-docker-proxy
merge upstream
This commit is contained in:
25
.github/workflows/stage.yaml
vendored
25
.github/workflows/stage.yaml
vendored
@@ -1,25 +0,0 @@
|
||||
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
|
||||
12
src/index.js
12
src/index.js
@@ -105,12 +105,22 @@ async function handleRequest(request) {
|
||||
const newReq = new Request(newUrl, {
|
||||
method: request.method,
|
||||
headers: request.headers,
|
||||
redirect: "follow",
|
||||
// don't follow redirect to dockerhub blob upstream
|
||||
redirect: isDockerHub ? "manual" : "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;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ CUSTOM_DOMAIN = "lolicon.in"
|
||||
[env.dev.vars]
|
||||
MODE = "debug"
|
||||
TARGET_UPSTREAM = "https://registry-1.docker.io"
|
||||
CUSTOM_DOMAIN = "exmaple.com"
|
||||
|
||||
[env.production]
|
||||
name = "cloudflare-docker-proxy"
|
||||
|
||||
Reference in New Issue
Block a user