Docker
服务搭建
Docker-笔记类
Docker-Wiki.js
Docker-Trilium(个人云笔记)
Docker-MrDoc(觅思文档)
Docker-MinDoc(文档管理系统)
Docker-Wiz(为知笔记)
Docker-Wizard(开源文档管理系统)
Docker-siyuan(思源笔记)
Docker-Athensresearch(雅典)
Docker-Logseq(日志序列)
Docker-Joplin Server(需搭配APP)
MarkDown-进阶
Docker-AFFiNE(白板文档)
Docker-Obsidian(黑曜石)
Html-文章保护
Docker-Memos(备忘录)
Docker-Etherpad(实时协作在线编辑器)
Docker-AppFlowy
Docker-DokuWiki(维基)
Docker-小书匠
Docker-MD(微信 Markdown编辑器)
Docker-Halo(个人博客)
闲置宽带利用
甜糖
网心云
点心云
Docker-JS TOOL(京豆)
Docker-Gitea(代码托管平台)
Git使用小技巧
Git-命令推送
Git-常用命令
Docker-CentOS
Docker-iperf3(网络测速)
Docker-QingLong(青龙面板)
🚫青龙-NolanJDCloud
青龙-Ninja
青龙-京豆
青龙-互助码
青龙-WxPusher(通知)
青龙-其他脚本
青龙-bilibili
青龙-短视频金币
青龙-常见问题
青龙-迁移
青龙-快速部署
Docker-EMQX(MQTT服务器)
EMQX-高级操作
Docker-Home Assistant
Docker-RustDesk(远程桌面)
Docker-邮箱系统
Docker-SRS(直播服务器)
Docker-Bitwarden(密码服务器)
Bitwarden-TOTP(双因素认证2FA)
Docker-书签/导航
Docker-OneNav
Docker-Flare
Docker-WebStack
Docker-GEEKAPE
Docker-nav(发现导航)
Docker-Linkding(网络书签)
Docker-Wallabag(网络书签)
Docker-Benotes(书签)
Docker-LyLme Spage(六零导航页)
Docker-Homarr(浏览器仪表板)
Docker-Sun-Panel
Docker-Nginx
Docker-nginxWebUI(反向代理)
Docker-Nginx Proxy Manager
Docker-Nginx Config(配置生成器)
Docker-Nginx UI
Nginx-配置详细说明
PHP扩展
Nginx-安全
Nginx-Shell管理脚本
Docker-Redis
Docker-Jupyter(Python在线环境)
JupyterHub(支持课程管理)
Jupyter(单用户)
Jupyter-OpenCV
JupyterHub-自构建
Docker-LiveTorrent(磁力链在线解析)
Docker-OpenVPN
OpenVPN-配置注释
OpenVPN-基础部署
OpenVPN-一键脚本部署
OpenVPN-访问内部设备
OpenVPN-ovpn-admin(WebUI)
Docker-Switch联机
Docker-网站统计
Docker-Umami
Docker-Matomo
Docker-IPsecVPN
Docker-Zerotier(虚拟组网)
ZeroTier-Planet(星球)
Zerotier-Moons(月亮)
Zerotier-伪根服务器(修改UI)
ZeroTier-局域组网
Docker-Linux
Docker-Screeps 服务器
Docker-Harbor(Docker 镜像服务器)
Harbor-镜像迁移
docker-mirror(镜像转存工具)
Docker-Reader(网文阅读器)
Docker-聊天类
Docker-Rocket.chat(IM聊天系统)
Docker-Fiora(二次元聊天室)
Docker-Mattermost(开发者聊天室)
Docker-唐僧叨叨
Docker-Mastodon
Docker-VoceChat
Docker-blogChat(在线聊天室)
Docker-NASTools(影音库工具)
Docker-Lottery(抽奖程序)
Docker-VSCode Web版
Docker-临时分享类
Docker-PasteMe(自销毁小纸条)
Docker-PasteBin(临时分享)
Docker-Pingvin Share(文件分享)
Docker-Snapdrop(局域网传输)
Docker-FileCodeBox(文件快递柜)
Docker-microbin(临时分享)
Docker-PairDrop(局域网传输)
Docker-FastSend(文件快传)
Docker-internal-chat(局域网文字/文件)
Docker-Enclosed(私密安全笔记)
Docker-任务管理类
Docker-TAIGA(看板)
Docker-Focalboard(看板)
Docker-DooTask(轻量级任务管理工具)
Docker-Vikunja(待办事项)
Docker-Tasks.md(任务管理板)
Docker-Send(私密文件分享)
Docker-ScreeGo(在线多人屏幕分享)
Docker-ChatGPT
ChatGPT(伪)-部署
ChatGPT-未测试项目
ChatGPT-ChatGPT Web
🚫ChatGPT-ChatGPT Vercel
🚫ChatGPT-PandoraNext(潘多拉)
🚫ChatGPT-PandoraNext-Helper(Token管理)
Docker-kkFileView(文件在线预览)
Docker-问卷考试类
Docker-学之思(开源考试系统)
Docker-文字识别类(OCR)
Docker-OCR(Python)
Docker-Paperless-ngx(无纸化)
Docker-短链类
Docker-Yourls(短链)
Worker短链(CloudFlare)
Docker-GreaterWMS(仓管系统)
Docker-内网穿透
Docker-Frp
Docker-NPS
Frp-客户端配置工具
Docker-Frp-Panel
Docker-OpenP2P
Docker-网盘
Docker-AList(云盘直链)
🚫Docker-FileRun(个人网盘)
Docker-腾飞WebOS
Docker-Cloudreve(支持WebDAV子账户)
Docker-Seafile
Docker-ZFile
Docker-Dufs(轻量文件服务器)
Docker-FileGator
Docker-SSH/远程桌面
Docker-Guacamole(远程桌面)
Docker-Nexterm(服务器管理软件)
Docker-Sshwifty(SSH&Telnet客户端)
Docker-Next Terminal(Web终端)
Docker-CF_Tunnels(隧道)
Docker-RouYi_WMS
Docker-图形化管理工具
Docker-Portainer(图形化管理工具)
Docker-SimpleDocker(Docker控制面板)
Docker-Easypanel(易面板)
Docker-DockerUI(国内图形化)
Docker-1Panel
Docker-宝塔
Docker-lazydocker(Shell UI)
Docker-⭐DPanel(可视化管理面板)
Docker-⭐Dockge(docker-compose管理器)
Docker-Dokploy(PaaS)
Docker-UpSnap(局域网唤醒)
Docker-Watchtower(自动更新)
Docker-RunnerGo(全栈测试)
Docker-Web工具箱
Docker-Stirling-PDF(PDF工具)
Docker-IT Tools(IT工具箱)
Docker-Reference(速查神器)
Docker-Photopea(在线PS)
Docker-miniPaint(在线PS)
Docker-Morphos(文件转换)
Docker-证件照片排版
Docker-网易云解锁
Docker-nondanee_UnblockNeteaseMusic
Docker-UnblockNeteaseMusic
Docker-LX Music_Sync(数据同步)
Docker-在线白板类
Docker-Wbo(协作白板)
Docker-Excalidraw+(在线白板)
Docker-tldraw
Docker-Cook(今天吃什么)
Docker-Android
Docker-QD(自动签到)
QD-使用说明
Docker-消息推送(通知)
Docker-Wecom酱
Docker-Gotify(消息通知)
Docker-WeChatBot(微信机器人)
Docker-lumen项目部署
Docker-简历构建器
Docker-Open Resume
Docker-Reactive Resume
Docker-照片备份
Docker-Immich
Docker-vlmcsd(KMS)
Docker-Papermerge(数字档案文件管理系统)
Docker-SearXNG(搜索引擎)
Docker-Snipe-IT(资产管理)
Docker-Moments(极简朋友圈)
Docker-neko(浏览器)
Docker-AsPoem(诗词网站)
Docker-CMS(内容管理系统)
Docker-Ikaros(个人内容管家)
Docker-JPress
Docker-OneKVM(类向日葵控控)
Docker-OS(系统)
Docker-DSM(群晖)
Docker-OSX(MacOS)
Docker-Puter(云端系统)
Docker-GodoOS(内网办公操作系统)
Docker-Nextcloud
Docker-KodCloud(可道云)
Docker-MacOS
Docker-Windows
Docker-Ferry(工单系统)
Docker-HivisionIDPhotos(AI证件照)
Docker-IPTVnator(IPTV播放器)
Docker-SQL工具
Docker-SQLynx
Docker-STUN/TURN(Coturn)
Docker-gocron(定时任务管理系统)
Docker-paopao-ce(微社区)
Docker-JSON Hero(JSON浏览器)
Docker-n8n(工作流自动化)
Docker-Aria2
Docker-NTP(时间服务器)
Docker-EasyTier(异地组网)
Linux-EasyTier
EasyTier-配置文件
Docker-Domain Admin(域管理员)
Docker-WPS
卷的使用
备份与还原
各种开源项目(未测试)
限制资源
开放端口调整
更换 Docker 源
镜像转存DockerHub
DockerHub 代理加速(Cloudflare Worker)
Docker 代理加速(Cloudflare Worker)
代理加速
⭐CF-Workers-docker(DockerHub 加速)
docker run 转 docker-compose
Docker 解释
Dockerfile(自建镜像)
使用第三方构建
多阶段构建(缩小体积)
Docker的备份服务器
Kasm(Web服务)
Docker-备份与还原
Docker-volume(卷)
Docker-network(网络)
Linux 安装 Docker
Windows 安装 Docker
Win7 安装 Docker
游戏服务器搭建
Docker-Valheim(英灵神殿)
Docker-jsnes(在线NES)
Docker-7DaysToDie(七日杀)
7DaysToDie-配置文件
Docker-Conan Exiles(流放者柯南)
Docker-noname(无名杀)
Docker-Epic游戏商城每周免费游戏
Docker-Terraria(泰拉瑞亚)
泰拉瑞亚-服务器
Terrari-存档同步
Docker-Mindustry(像素工厂)
Docker-Habitica(习惯养成RPG)
Docker-RetroArch(在线模拟器)
Docker-vue-idle-game(轮回勇士传说)
Docker-Phira(Phigros 二创版)
Docker-Pterodactyl(翼龙面板⭐)
Pterodactyl-自建预设(游戏部署脚本)
Docker-GamePanelX-V3(游戏面板)
Docker-MCSManager(游戏面板⭐)
Docker-Easy-WI(游戏面板)
Docker-常见问题处理
Podman(Docker替代品)
Docker-Linux Command(Linux命令搜索引擎)
Docker-修改存储位置
Dockerc(编译为独立二进制文件)
slim(镜像瘦身)
Docker-API(远程连接)
Docker-cloudbak(云朵备份)
本文档使用 MrDoc 发布
-
+
首页
⭐CF-Workers-docker(DockerHub 加速)
使用 `Cloudflare Worker` 部署代理 **相关链接:** - Cloudflare:https://dash.cloudflare.com/ - CF-Workers-docker.io:https://github.com/cmliu/CF-Workers-docker.io - 文档:https://vercel.blog.cmliussss.com/p/CF-Workers-docker.io/ ## [CF-Workers-docker.io](https://github.com/cmliu/CF-Workers-docker.io) **可以添加变量来启用保护(不显示主页):** - URL:伪装URL,填写 `nginx` 启用内部nginx伪装 - URL302:重定向URL,优先值高于URL `worker.js`,自修改版本,增加使用说明 ```js const domain = '<你的域名>' // 修改为你的域名 // 下面是配置项,无需更改 let hub_host = 'registry-1.docker.io' // Docker镜像仓库主机地址 const auth_url = 'https://auth.docker.io' // Docker认证服务器地址 let workers_url = `https://${domain}` // 自定义的工作服务器地址,无需修改 let 屏蔽爬虫UA = ['netcraft'] // 屏蔽爬虫的User-Agent列表 // 根据主机名选择对应的上游地址 function routeByHosts(host) { const routes = { // 定义路由表 "docker": "registry-1.docker.io", // docker.<你的域名> "quay": "quay.io", // quay.<你的域名> "gcr": "gcr.io", // gcr.<你的域名> "k8s-gcr": "k8s.gcr.io", // k8s-gcr.<你的域名> "k8s": "registry.k8s.io", // k8s.<你的域名> "ghcr": "ghcr.io", // ghcr.<你的域名> "cloudsmith": "docker.cloudsmith.io", // cloudsmith.<你的域名> "nvcr": "nvcr.io", // nvcr.<你的域名> } if (host in routes) return [ routes[host], false ] else return [ hub_host, true ] } /** @type {RequestInit} */ const PREFLIGHT_INIT = { headers: new Headers({ // 预检请求配置 'access-control-allow-origin': '*', // 允许所有来源 'access-control-allow-methods': 'GET,POST,PUT,PATCH,TRACE,DELETE,HEAD,OPTIONS', // 允许的HTTP方法 'access-control-max-age': '1728000', // 预检请求的缓存时间 }), } /** * 构造响应 * @param {any} body 响应体 * @param {number} status 响应状态码 * @param {Object<string, string>} headers 响应头 */ function makeRes(body, status = 200, headers = {}) { headers['access-control-allow-origin'] = '*' // 允许所有来源 return new Response(body, { status, headers }) // 返回新构造的响应 } /** * 构造新的URL对象 * @param {string} urlStr URL字符串 */ function newUrl(urlStr) { try { return new URL(urlStr) // 尝试构造新的URL对象 } catch (err) { return null // 构造失败返回null } } function isUUID(uuid) { // 定义一个正则表达式来匹配 UUID 格式 const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i; return uuidRegex.test(uuid); // 使用正则表达式测试 UUID 字符串 } async function nginx() { const text = ` <!DOCTYPE html> <html> <head> <title>Welcome to nginx!</title> <style> body { width: 35em; margin: 0 auto; font-family: Tahoma, Verdana, Arial, sans-serif; } </style> </head> <body> <h1>Welcome to nginx!</h1> <p>If you see this page, the nginx web server is successfully installed and working. Further configuration is required.</p> <p>For online documentation and support please refer to <a href="http://nginx.org/">nginx.org</a>.<br/> Commercial support is available at <a href="http://nginx.com/">nginx.com</a>.</p> <p><em>Thank you for using nginx.</em></p> </body> </html> ` return text } async function searchInterface() { const text = ` <!DOCTYPE html> <html> <head> <title>Docker Hub 加速_ZWZW</title> <style> body { /* font-family: Arial, sans-serif; */ display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100vh; margin: 0; background: linear-gradient(to right, rgb(28, 143, 237), rgb(29, 99, 237)); } h1 { font-size: 1.8em; /* 设置标题的字体大小 */ margin-block-start: 0em; /* 设置标题的上边距 */ margin-block-end: 0.5em; /* 设置标题的下边距 */ } h3 { font-size: 1.2em; /* 设置标题的字体大小 */ margin-block-start: 0.5em; /* 设置标题的上边距 */ margin-block-end: 0.2em; /* 设置标题的下边距 */ } .logo { margin-bottom: 0px; } .search-container { padding: 10px; display: flex; align-items: center; } #search-input { padding: 10px; font-size: 16px; border: 1px solid #ddd; border-radius: 4px; width: 300px; margin-right: 10px; } #search-button { padding: 10px; background-color: rgba(255, 255, 255, 0.2); /* 设置白色,透明度 */ border: none; border-radius: 4px; cursor: pointer; width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; } #search-button svg { width: 24px; height: 24px; } .container { max-width: 800px; margin: 0 auto; padding: 15px; background: rgba(255, 255, 255, 0.4); border-radius: 20px; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); } pre { margin-block-start: 0.01em; /* 设置标题的上边距 */ margin-block-end: 0.01em; /* 设置标题的下边距 */ background: #2d2d2d; color: #f8f8f2; padding: 15px; border-radius: 15px; overflow-x: auto; position: relative; } pre::before { content: " "; display: block; position: absolute; top: 10px; left: 10px; width: 12px; height: 12px; background: #ff5f56; border-radius: 50%; box-shadow: 20px 0 0 #ffbd2e, 40px 0 0 #27c93f; } code { font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace; font-size: 0.875em; } .copy-button { position: absolute; top: 10px; right: 10px; background: #007aff; color: white; border: none; padding: 5px 10px; border-radius: 5px; cursor: pointer; opacity: 0; transition: opacity 0.3s; } pre:hover .copy-button { opacity: 1; } .by { color: rgba(255, 255, 255, 0.8); margin-block-start: 0.5em; /* 设置标题的上边距 */ margin-block-end: 0em; /* 设置标题的下边距 */ } .exegesis { color: rgba(128, 179, 255, 0.8); } </style> </head> <body> <div class="logo"> <svg xmlns="http:#www.w3.org/2000/svg" viewBox="0 0 24 18" fill="#ffffff" width="100" height="75"> <path d="M23.763 6.886c-.065-.053-.673-.512-1.954-.512-.32 0-.659.03-1.01.087-.248-1.703-1.651-2.533-1.716-2.57l-.345-.2-.227.328a4.596 4.596 0 0 0-.611 1.433c-.23.972-.09 1.884.403 2.666-.596.331-1.546.418-1.744.42H.752a.753.753 0 0 0-.75.749c-.007 1.456.233 2.864.692 4.07.545 1.43 1.355 2.483 2.409 3.13 1.181.725 3.104 1.14 5.276 1.14 1.016 0 2.03-.092 2.93-.266 1.417-.273 2.705-.742 3.826-1.391a10.497 10.497 0 0 0 2.61-2.14c1.252-1.42 1.998-3.005 2.553-4.408.075.003.148.005.221.005 1.371 0 2.215-.55 2.68-1.01.505-.5.685-.998.704-1.053L24 7.076l-.237-.19Z"></path> <path d="M2.216 8.075h2.119a.186.186 0 0 0 .185-.186V6a.186.186 0 0 0-.185-.186H2.216A.186.186 0 0 0 2.031 6v1.89c0 .103.083.186.185.186Zm2.92 0h2.118a.185.185 0 0 0 .185-.186V6a.185.185 0 0 0-.185-.186H5.136A.185.185 0 0 0 4.95 6v1.89c0 .103.083.186.186.186Zm2.964 0h2.118a.186.186 0 0 0 .185-.186V6a.186.186 0 0 0-.185-.186H8.1A.185.185 0 0 0 7.914 6v1.89c0 .103.083.186.186.186Zm2.928 0h2.119a.185.185 0 0 0 .185-.186V6a.185.185 0 0 0-.185-.186h-2.119a.186.186 0 0 0-.185.186v1.89c0 .103.083.186.185.186Zm-5.892-2.72h2.118a.185.185 0 0 0 .185-.186V3.28a.186.186 0 0 0-.185-.186H5.136a.186.186 0 0 0-.186.186v1.89c0 .103.083.186.186.186Zm2.964 0h2.118a.186.186 0 0 0 .185-.186V3.28a.186.186 0 0 0-.185-.186H8.1a.186.186 0 0 0-.186.186v1.89c0 .103.083.186.186.186Zm2.928 0h2.119a.185.185 0 0 0 .185-.186V3.28a.186.186 0 0 0-.185-.186h-2.119a.186.186 0 0 0-.185.186v1.89c0 .103.083.186.185.186Zm0-2.72h2.119a.186.186 0 0 0 .185-.186V.56a.185.185 0 0 0-.185-.186h-2.119a.186.186 0 0 0-.185.186v1.89c0 .103.083.186.185.186Zm2.955 5.44h2.118a.185.185 0 0 0 .186-.186V6a.185.185 0 0 0-.186-.186h-2.118a.185.185 0 0 0-.185.186v1.89c0 .103.083.186.185.186Z"></path> </svg> </div> <div class="search-container"> <input type="text" id="search-input" placeholder="搜索 Docker Hub(仅搜索,拉取需加速)"> <button id="search-button"> <svg focusable="false" aria-hidden="true" viewBox="0 0 24 24" fill="none" xmlns="http:#www.w3.org/2000/svg"> <path d="M21 21L16.65 16.65M19 11C19 15.4183 15.4183 19 11 19C6.58172 19 3 15.4183 3 11C3 6.58172 6.58172 3 11 3C15.4183 3 19 6.58172 19 11Z" stroke="white" fill="none" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path> </svg> </button> </div> <div class="container"> <center><h1>镜像加速使用说明</h1></center> <h3>registry-mirrors 换源加速:</h3> <pre><code> sudo tee /etc/docker/daemon.json <<EOF { "registry-mirrors": ["https://docker.${domain}"] } EOF</code><button class="copy-button" onclick="copyCode(this)">复制代码</button></pre> <h3>直接使用:</h3> <pre><code> <span class="exegesis"># ############### DockerHub ###############</span> docker pull alpine:latest <span class="exegesis"># 源拉取</span> docker pull docker.${domain}/alpine:latest <span class="exegesis"># <a class="exegesis" href="https://docker.${domain}">加速拉取</a></span> <span class="exegesis"># ############### quay.io ###############</span> docker pull quay.io/alpine:latest <span class="exegesis"># 源拉取</span> docker pull quay.${domain}/alpine:latest <span class="exegesis"># <a class="exegesis" href="https://quay.${domain}">加速拉取</a></span> <span class="exegesis"># ############### gcr.io ###############</span> docker pull gcr.io/alpine:latest <span class="exegesis"># 源拉取</span> docker pull gcr.${domain}/alpine:latest <span class="exegesis"># <a class="exegesis" href="https://gcr.${domain}">加速拉取</a></span> <span class="exegesis"># ############### k8s.gcr.io ###############</span> docker pull k8s.gcr.io/alpine:latest <span class="exegesis"># 源拉取</span> docker pull k8s-gcr.${domain}/alpine:latest <span class="exegesis"># <a class="exegesis" href="https://k8s-gcr.${domain}">加速拉取</a></span> <span class="exegesis"># ############### registry.k8s.io ###############</span> docker pull registry.k8s.io/alpine:latest <span class="exegesis"># 源拉取</span> docker pull k8s.${domain}/alpine:latest <span class="exegesis"># <a class="exegesis" href="https://k8s.${domain}">加速拉取</a></span> <span class="exegesis"># ############### ghcr.io ###############</span> docker pull ghcr.io/alpine:latest <span class="exegesis"># 源拉取</span> docker pull ghcr.${domain}/alpine:latest <span class="exegesis"># <a class="exegesis" href="https://ghcr.${domain}">加速拉取</a></span> <span class="exegesis"># ############### docker.cloudsmith.io ###############</span> docker pull docker.cloudsmith.io/alpine:latest <span class="exegesis"># 源拉取</span> docker pull cloudsmith.${domain}/alpine:latest <span class="exegesis"># <a class="exegesis" href="https://cloudsmith.${domain}">加速拉取</a></span> <span class="exegesis"># ############### nvcr.io ###############</span> docker pull nvcr.io/alpine:latest <span class="exegesis"># 源拉取</span> docker pull nvcr.${domain}/alpine:latest <span class="exegesis"># <a class="exegesis" href="https://nvcr.${domain}">加速拉取</a></span> </code></pre> </div> <div class="by"> Docker加速 <a class="by" href="https://doc.918178.xyz" target="_blank">造物者W</a> </div> <script> // 复制代码按钮的点击事件处理函数 function performSearch() { const query = document.getElementById('search-input').value; if (query) { window.location.href = '/search?q=' + encodeURIComponent(query); } } document.getElementById('search-button').addEventListener('click', performSearch); document.getElementById('search-input').addEventListener('keypress', function(event) { if (event.key === 'Enter') { performSearch(); } }); // 添加复制代码按钮的功能 function copyCode(button) { const code = button.previousSibling; const textArea = document.createElement('textarea'); textArea.value = code.textContent; document.body.appendChild(textArea); textArea.select(); document.execCommand('copy'); document.body.removeChild(textArea); button.textContent = '已复制'; setTimeout(() => { button.textContent = '复制代码'; }, 2000); } </script> </body> </html> ` return text } export default { async fetch(request, env, ctx) { const getReqHeader = (key) => request.headers.get(key) // 获取请求头 let url = new URL(request.url) // 解析请求URL const userAgentHeader = request.headers.get('User-Agent') const userAgent = userAgentHeader ? userAgentHeader.toLowerCase() : "null" if (env.UA) 屏蔽爬虫UA = 屏蔽爬虫UA.concat(await ADD(env.UA)) workers_url = `https://${url.hostname}` const pathname = url.pathname // 获取请求路径 const ns = url.searchParams.get('ns') // 获取请求参数中的 ns const hostname = url.searchParams.get('hubhost') || url.hostname // 获取请求参数中的 hubhost,如果没有则使用 url.hostname const hostTop = hostname.split('.')[0] // 获取主机名的第一部分 let checkHost; // 在这里定义 checkHost 变量 // 如果存在 ns 参数,优先使用它来确定 hub_host if (ns) { if (ns === 'docker.io') { hub_host = 'registry-1.docker.io' // 设置上游地址为 registry-1.docker.io } else { hub_host = ns; // 直接使用 ns 作为 hub_host } } else { checkHost = routeByHosts(hostTop) hub_host = checkHost[0] // 获取上游地址 } const fakePage = checkHost ? checkHost[1] : false; // 确保 fakePage 不为 undefined console.log(`域名头部: ${hostTop}\n反代地址: ${hub_host}\n伪装首页: ${fakePage}`) const isUuid = isUUID(pathname.split('/')[1].split('/')[0]) if (屏蔽爬虫UA.some(fxxk => userAgent.includes(fxxk)) && 屏蔽爬虫UA.length > 0) { // 屏蔽爬虫UA return new Response(await nginx(), { // 首页改成一个nginx伪装页 headers: { 'Content-Type': 'text/html; charset=UTF-8' }, }) } const conditions = [ isUuid, pathname.includes('/_'), pathname.includes('/r/'), pathname.includes('/v2/repositories'), pathname.includes('/v2/user'), pathname.includes('/v2/orgs'), pathname.includes('/v2/_catalog'), pathname.includes('/v2/categories'), pathname.includes('/v2/feature-flags'), pathname.includes('search'), pathname.includes('source'), pathname == '/', pathname == '/favicon.ico', pathname == '/auth/profile', ]; if (conditions.some(condition => condition) && (fakePage === true || hostTop == 'docker')) { if (env.URL302) { // 如果有302重定向地址,则跳转 return Response.redirect(env.URL302, 302) } else if (env.URL) { // 如果有伪装地址,则伪装 if (env.URL.toLowerCase() == 'nginx') { //首页改成一个nginx伪装页 return new Response(await nginx(), { headers: { 'Content-Type': 'text/html; charset=UTF-8', }, }) } else return fetch(new Request(env.URL, request)) } else if (url.pathname == '/'){ return new Response(await searchInterface(), { headers: { 'Content-Type': 'text/html; charset=UTF-8', }, }) } const newUrl = new URL("https://registry.hub.docker.com" + pathname + url.search) // 构建新的 URL const headers = new Headers(request.headers) // 复制原始请求的标头 headers.set('Host', 'registry.hub.docker.com') // 确保 Host 头部被替换为 hub.docker.com const newRequest = new Request(newUrl, { method: request.method, headers: headers, body: request.method !== 'GET' && request.method !== 'HEAD' ? await request.blob() : null, redirect: 'follow' }) return fetch(newRequest) } // 修改包含 %2F 和 %3A 的请求 if (!/%2F/.test(url.search) && /%3A/.test(url.toString())) { let modifiedUrl = url.toString().replace(/%3A(?=.*?&)/, '%3Alibrary%2F') url = new URL(modifiedUrl) console.log(`handle_url: ${url}`) // 打印处理后的URL } // 处理token请求 if (url.pathname.includes('/token')) { let token_parameter = { headers: { 'Host': 'auth.docker.io', 'User-Agent': getReqHeader("User-Agent"), 'Accept': getReqHeader("Accept"), 'Accept-Language': getReqHeader("Accept-Language"), 'Accept-Encoding': getReqHeader("Accept-Encoding"), 'Connection': 'keep-alive', 'Cache-Control': 'max-age=0' } } let token_url = auth_url + url.pathname + url.search // 修改token请求路径 return fetch(new Request(token_url, request), token_parameter) // 返回token请求 } // 修改 /v2/ 请求路径 if ( hub_host == 'registry-1.docker.io' && /^\/v2\/[^/]+\/[^/]+\/[^/]+$/.test(url.pathname) && !/^\/v2\/library/.test(url.pathname)) { // 匹配 /v2/ 请求路径 //url.pathname = url.pathname.replace(/\/v2\//, '/v2/library/') url.pathname = '/v2/library/' + url.pathname.split('/v2/')[1] // 替换为library console.log(`modified_url: ${url.pathname}`) // 打印修改后的URL } // 更改请求的主机名 url.hostname = hub_host // 构造请求参数 let parameter = { headers: { 'Host': hub_host, 'User-Agent': getReqHeader("User-Agent"), 'Accept': getReqHeader("Accept"), 'Accept-Language': getReqHeader("Accept-Language"), 'Accept-Encoding': getReqHeader("Accept-Encoding"), 'Connection': 'keep-alive', 'Cache-Control': 'max-age=0' }, cacheTtl: 3600 // 缓存时间 } // 添加Authorization头 if (request.headers.has("Authorization")) { parameter.headers.Authorization = getReqHeader("Authorization") } // 发起请求并处理响应 let original_response = await fetch(new Request(url, request), parameter) let original_response_clone = original_response.clone() let original_text = original_response_clone.body let response_headers = original_response.headers let new_response_headers = new Headers(response_headers) let status = original_response.status // 修改 Www-Authenticate 头 if (new_response_headers.get("Www-Authenticate")) { let auth = new_response_headers.get("Www-Authenticate") let re = new RegExp(auth_url, 'g') new_response_headers.set("Www-Authenticate", response_headers.get("Www-Authenticate").replace(re, workers_url)) } // 处理重定向 if (new_response_headers.get("Location")) { return httpHandler(request, new_response_headers.get("Location")) } // 返回修改后的响应 let response = new Response(original_text, { status, headers: new_response_headers }) return response } } /** * 处理HTTP请求 * @param {Request} req 请求对象 * @param {string} pathname 请求路径 */ function httpHandler(req, pathname) { const reqHdrRaw = req.headers // 请求头 // 处理预检请求 if (req.method === 'OPTIONS' && reqHdrRaw.has('access-control-request-headers') ) { return new Response(null, PREFLIGHT_INIT) } let rawLen = '' // 原始响应长度 const reqHdrNew = new Headers(reqHdrRaw) // 请求头 const refer = reqHdrNew.get('referer') let urlStr = pathname // 请求URL const urlObj = newUrl(urlStr) // URL对象 /** @type {RequestInit} */ const reqInit = { method: req.method, headers: reqHdrNew, redirect: 'follow', body: req.body } return proxy(urlObj, reqInit, rawLen) } /** * 代理请求 * @param {URL} urlObj URL对象 * @param {RequestInit} reqInit 请求初始化对象 * @param {string} rawLen 原始长度 */ async function proxy(urlObj, reqInit, rawLen) { const res = await fetch(urlObj.href, reqInit) const resHdrOld = res.headers const resHdrNew = new Headers(resHdrOld) // 验证长度 if (rawLen) { const newLen = resHdrOld.get('content-length') || '' const badLen = (rawLen !== newLen) if (badLen) { return makeRes(res.body, 400, { '--error': `bad len: ${newLen}, except: ${rawLen}`, 'access-control-expose-headers': '--error', }) } } const status = res.status resHdrNew.set('access-control-expose-headers', '*') resHdrNew.set('access-control-allow-origin', '*') resHdrNew.set('Cache-Control', 'max-age=1500') // 删除不必要的头 resHdrNew.delete('content-security-policy') resHdrNew.delete('content-security-policy-report-only') resHdrNew.delete('clear-site-data') return new Response(res.body, { status, headers: resHdrNew }) } async function ADD(envadd) { var addtext = envadd.replace(/[ |"'\r\n]+/g, ',').replace(/,+/g, ',') // 将空格、双引号、单引号和换行符替换为逗号 if (addtext.charAt(0) == ',') addtext = addtext.slice(1) if (addtext.charAt(addtext.length - 1) == ',') addtext = addtext.slice(0, addtext.length - 1) const add = addtext.split(',') return add } ``` ## 我部署的 ```bash # ############### DockerHub ############### docker pull alpine:latest # 源拉取 docker pull docker.918178.xyz/alpine:latest # 加速拉取 # ############### quay.io ############### docker pull quay.io/alpine:latest # 源拉取 docker pull quay.918178.xyz/alpine:latest # 加速拉取 # ############### gcr.io ############### docker pull gcr.io/alpine:latest # 源拉取 docker pull gcr.918178.xyz/alpine:latest # 加速拉取 # ############### k8s.gcr.io ############### docker pull k8s.gcr.io/alpine:latest # 源拉取 docker pull k8s-gcr.918178.xyz/alpine:latest # 加速拉取 # ############### registry.k8s.io ############### docker pull registry.k8s.io/alpine:latest # 源拉取 docker pull k8s.918178.xyz/alpine:latest # 加速拉取 # ############### ghcr.io ############### docker pull ghcr.io/alpine:latest # 源拉取 docker pull ghcr.918178.xyz/alpine:latest # 加速拉取 # ############### docker.cloudsmith.io ############### docker pull docker.cloudsmith.io/alpine:latest # 源拉取 docker pull cloudsmith.918178.xyz/alpine:latest # 加速拉取 # ############### nvcr.io ############### docker pull nvcr.io/alpine:latest # 源拉取 docker pull nvcr.918178.xyz/alpine:latest # 加速拉取 ```
造物者W
2025年1月1日 15:14
转发文档
收藏文档
上一篇
下一篇
手机扫码
复制链接
手机扫一扫转发分享
复制链接
Markdown文件
分享
链接
类型
密码
更新密码