已复活https://linux.do/t/topic/185961
解决了不代理auth.docker.io的问题
主要使用Nginx来进行反代
服务器高防,无限流量,已续费1年,长期续费
地址:https://docker.melikeme.cn/
一键脚本:bash <(curl -Ls https://docker.melikeme.cn/docker.sh)
脚本/引导页源码:
源码.zip (5.5 KB)
放个Nginx反代核心配置文件,可用于宝塔,1p,裸Nginx
# 使用 map 来匹配和替换 upstream 头部中的 auth.docker.io
map $upstream_http_www_authenticate $m_www_authenticate_replaced {
"~auth\.docker\.io(.*)" "$1";
default "";
}
map $m_www_authenticate_replaced $m_final_replaced {
"~(.*)" 'Bearer realm=\"$scheme://$host$1';
default "";
}
server
{
proxy_ssl_server_name on;
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_hide_header www-authenticate;
add_header www-authenticate "$m_final_replaced" always;
# 关闭缓存
proxy_buffering off;
# 转发认证相关
proxy_set_header Authorization $http_authorization;
proxy_pass_header Authorization;
# 对 upstream 状态码检查,实现 error_page 错误重定向
proxy_intercept_errors on;
recursive_error_pages on;
# 根据状态码执行对应操作,以下为301、302、307状态码都会触发
error_page 301 302 307 = @handle_redirect;
location ~* ^/(v2|v1|v1.29)/ {
proxy_pass https://registry-1.docker.io;
proxy_set_header Host registry-1.docker.io;
proxy_read_timeout 18000s;
proxy_send_timeout 18000s;
send_timeout 18000s;
proxy_connect_timeout 18000s;
}
#处理重定向
location @handle_redirect {
resolver 1.1.1.1;
set $saved_redirect_location '$upstream_http_location';
proxy_pass $saved_redirect_location;
}
#代理授权地址
location ^~ /token {
proxy_pass https://auth.docker.io;
proxy_set_header Host auth.docker.io;
}
#一键申请SSL证书验证目录相关设置
location ~ \.well-known{
allow all;
}
}