惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

罗磊的独立博客
SecWiki News
SecWiki News
酷 壳 – CoolShell
酷 壳 – CoolShell
爱范儿
爱范儿
量子位
M
MIT News - Artificial intelligence
GbyAI
GbyAI
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
TaoSecurity Blog
TaoSecurity Blog
博客园 - 【当耐特】
H
Heimdal Security Blog
腾讯CDC
The Last Watchdog
The Last Watchdog
Security Archives - TechRepublic
Security Archives - TechRepublic
Hacker News: Ask HN
Hacker News: Ask HN
S
Schneier on Security
Microsoft Security Blog
Microsoft Security Blog
WordPress大学
WordPress大学
博客园 - 司徒正美
Recent Commits to openclaw:main
Recent Commits to openclaw:main
C
Cybersecurity and Infrastructure Security Agency CISA
S
SegmentFault 最新的问题
大猫的无限游戏
大猫的无限游戏
Application and Cybersecurity Blog
Application and Cybersecurity Blog
F
Full Disclosure
有赞技术团队
有赞技术团队
T
Tailwind CSS Blog
Engineering at Meta
Engineering at Meta
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
T
Threatpost
月光博客
月光博客
A
Arctic Wolf
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
雷峰网
雷峰网
T
Troy Hunt's Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
The Cloudflare Blog
D
DataBreaches.Net
O
OpenAI News
L
LINUX DO - 最新话题
宝玉的分享
宝玉的分享
小众软件
小众软件
V
Vulnerabilities – Threatpost
A
About on SuperTechFans
人人都是产品经理
人人都是产品经理
T
The Exploit Database - CXSecurity.com
Martin Fowler
Martin Fowler
美团技术团队
P
Privacy International News Feed

九月的风

OneXPlayer 飞行家F1Pro「新玩具」 - 九月的风 终不似,少年游「摩旅中国」 - 九月的风 SSHPASS 免交互 SCP 传输文件「备份」 - 九月的风 海尔随身WIFI MF761W 焊接SIM卡槽「打火机工艺」 - 九月的风 海尔随身WIFI F231ZC/M23L/761W 刷机去控教程 - 九月的风 「备份」Nginx 反代 Cloudflare 站点 - 九月的风 「自作」Chrome_123.0.6312.123_64bit_Portable - 九月的风 Chrome 浏览器关闭左上角搜索标签页的解决办法 - 九月的风 「摘抄」Wordpress 网站性能优化指南(免插件) - 九月的风
docker hub 自建镜像加速「可用」 - 九月的风
September · 2025-08-25 · via 九月的风

在拉取镜像时发现之前使用的代理已经失效了,而且 auth.docker.io 也被墙,导致网上很多教程都失效了,搜索到一个可用的就写下来当作备忘录。

有两种自建方案,一个是 nginx 反代,一个是使用 CloudFlare Worker 搭建。

nginx:

location /v2/ {
   proxy_pass https://registry-1.docker.io;  # Docker Hub 的官方镜像仓库
   proxy_set_header Host registry-1.docker.io;
   proxy_set_header X-Real-IP $remote_addr;
   proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
   proxy_set_header X-Forwarded-Proto $scheme;

   # 关闭缓存
   proxy_buffering off;

   # 转发认证相关的头部
   proxy_set_header Authorization $http_authorization;
   proxy_pass_header  Authorization;

   # 重写 www-authenticate 头为你的反代地址
   proxy_hide_header www-authenticate;
   add_header www-authenticate 'Bearer realm="https://xxx/token",service="registry.docker.io"' always;
   # always 参数确保该头部在返回 401 错误时无论什么情况下都会被添加。

   # 对 upstream 状态码检查,实现 error_page 错误重定向
   proxy_intercept_errors on;
   # error_page 指令默认只检查了第一次后端返回的状态码,开启后可以跟随多次重定向。
   recursive_error_pages on;
   # 根据状态码执行对应操作,以下为301、302、307状态码都会触发
   error_page 301 302 307 = @handle_redirect;

            }
   # 处理 Docker OAuth2 Token 认证请求
location /token {
   resolver 8.8.8.8 valid=600s;
   proxy_pass https://auth.docker.io;  # Docker 认证服务器

   # 设置请求头,确保转发正确
   proxy_set_header Host auth.docker.io;
   proxy_set_header X-Real-IP $remote_addr;
   proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
   proxy_set_header X-Forwarded-Proto $scheme;

   # 传递 Authorization 头信息,获取 Token
   proxy_set_header Authorization $http_authorization;
   proxy_pass_header Authorization;

   # 禁用缓存
   proxy_buffering off;
            }
   location @handle_redirect {
   resolver 8.8.8.8;
   set $saved_redirect_location '$upstream_http_location';
   proxy_pass $saved_redirect_location;
            }

CloudFlare Worker:

https://github.com/cmliu/CF-Workers-docker.io

代码转载:https://blog.lty520.faith