刚刷到 t/1095188 贴,看到还有人用 github 的方案,比较麻烦,分享一下我自己用的方案。
需要有一台可以正常访问 https://hub.docker.com/ 的服务器,我用的是华为云香港,用的开发者认证送的 401 元无门槛优惠券开通了 11 个月,区域 中国-香港 2 核 | 2GiB | 系统盘 40GiB | 流量包 1,024GB | 峰值带宽 30Mbit/s
我是用的是 nginx 反向代理的方案,比较方便,直接贴出配置
set_real_ip_from 0.0.0.0/0; real_ip_header CF-Connecting-IP; client_max_body_size 2G; underscores_in_headers on; resolver 8.8.8.8 ipv6=off; resolver_timeout 10s; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $http_connection; proxy_set_header Accept-Encoding ""; proxy_ssl_session_reuse off; proxy_ssl_server_name on; proxy_http_version 1.1; proxy_buffering off; proxy_request_buffering off; proxy_max_temp_file_size 0; proxy_connect_timeout 864000s; proxy_read_timeout 864000s; proxy_send_timeout 864000s; send_timeout 864000s; location /v2/ { proxy_pass https://registry-1.docker.io; proxy_set_header Host registry-1.docker.io; header_filter_by_lua_block { local www_auth = ngx.var.upstream_http_www_authenticate if www_auth then local new_www_auth = string.gsub(www_auth, "auth.docker.io", "docker.kegui.net") # 这个地方 上面的 docker.kegui.net 需要改成自己的域名 ngx.header['www-authenticate'] = new_www_auth end } proxy_intercept_errors on; recursive_error_pages on; error_page 301 302 307 = @handle_redirect; error_log /dev/null; access_log /www/wwwlogs/docker.log; } location /token { error_log /dev/null; access_log /dev/null; proxy_pass https://auth.docker.io; proxy_set_header Host auth.docker.io; } location @handle_redirect { set $saved_redirect_location '$upstream_http_location'; proxy_pass $saved_redirect_location; }
https://docker.kegui.net/ 这个是我搭建好的,自己也用不了多少流量,大家可以一起用。
1 zeromake 310 天前 好像可以用 caddy 直接做代理,还可以自动加 ssl ,caddy 还可以加认证防刷 |