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

推荐订阅源

Forbes - Security
Forbes - Security
GbyAI
GbyAI
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
S
SegmentFault 最新的问题
Y
Y Combinator Blog
Recorded Future
Recorded Future
博客园 - Franky
I
InfoQ
T
The Blog of Author Tim Ferriss
Recent Announcements
Recent Announcements
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
博客园_首页
阮一峰的网络日志
阮一峰的网络日志
T
Tailwind CSS Blog
Cyberwarzone
Cyberwarzone
The Register - Security
The Register - Security
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
雷峰网
雷峰网
P
Palo Alto Networks Blog
G
GRAHAM CLULEY
Cloudbric
Cloudbric
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
MongoDB | Blog
MongoDB | Blog
F
Full Disclosure
Google DeepMind News
Google DeepMind News
Recent Commits to openclaw:main
Recent Commits to openclaw:main
C
Check Point Blog
爱范儿
爱范儿
The GitHub Blog
The GitHub Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
W
WeLiveSecurity
T
Threat Research - Cisco Blogs
U
Unit 42
N
Netflix TechBlog - Medium
The Cloudflare Blog
Spread Privacy
Spread Privacy
Microsoft Azure Blog
Microsoft Azure Blog
美团技术团队
T
Troy Hunt's Blog
Engineering at Meta
Engineering at Meta
H
Heimdal Security Blog
TaoSecurity Blog
TaoSecurity Blog
C
Cybersecurity and Infrastructure Security Agency CISA
T
Tenable Blog
B
Blog
S
Securelist
H
Hacker News: Front Page
Google Online Security Blog
Google Online Security Blog
G
Google Developers Blog

九月的风

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