自建docker hub镜像

里面写了用cf work的方案以及用nginx反代的方案,cf work用个优选ip可能速度还行,不过对不同地区和运营商区别有点大(而且貌似得改hosts才能用优选,不咋方便)
也能用nginx反代,不过速度依赖于自己服务器的线路,9929+cmin2就已经接近于用境内的镜像的速度了
(相比各位手头都得有两个闲着的小鸡吧)

15 个赞

点赞

今天上午也倒腾了一会,nginx已经成功了

2 个赞

好棒!

正好搞一搞,Mark了

好东西

厉害了

说鸡不说吧

很不错

我选择服务器跑xray,直接通过代理跑流量操作,也稳得很

1 个赞

nginx不成功,泪目了

我之前也是用代理
不过系统经常迁移,还得先跑代理,然后再重建容器,有点麻烦
直接建个反代,把镜像id一改就能一直用了

:joy:
没注意

贴下我的配置

server {
    listen       80;
    listen       443  ssl;
    http2        on;
    server_name  docker.xxxx.org;

    ssl_certificate  /opt/module/openresty/nginx/cert/cert.pem;
    ssl_certificate_key /opt/module/openresty/nginx/cert/key.pem;
    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_ciphers 'ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256';
    ssl_prefer_server_ciphers on;
    ssl_session_cache shared:SSL:10m;
    ssl_session_timeout 10m;

    if ($scheme = http) {
        return 301 https://$server_name$request_uri;
    }

    access_log  logs/access.log main;
    error_log   logs/error.log;
	
    # Docker Hub 默认代理
    location / {

        if ($request_method = 'OPTIONS') {
            add_header 'Access-Control-Allow-Origin' '*';
            add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, PATCH, TRACE, DELETE, HEAD, OPTIONS';
            add_header 'Access-Control-Max-Age' '1728000';
            add_header 'Content-Type' 'text/plain charset=UTF-8';
            add_header 'Content-Length' '0';
            return 204;
        }

        proxy_ssl_server_name on;
        proxy_pass https://registry-1.docker.io;
        proxy_set_header Host registry-1.docker.io;
        proxy_set_header User-Agent $http_user_agent;
        proxy_set_header Accept $http_accept;
        proxy_set_header Accept-Language $http_accept_language;
        proxy_set_header Accept-Encoding $http_accept_encoding;
        proxy_set_header Connection "keep-alive";
        proxy_set_header Cache-Control "max-age=0";
        proxy_redirect default;
        proxy_redirect ~*auth.docker.io https://docker.xxxx.org;

        # 设置 CORS 和缓存控制
        add_header 'Access-Control-Allow-Origin' '*';
        add_header 'Access-Control-Expose-Headers' '*';
        add_header 'Cache-Control' 'max-age=1500';
    }

    # 对 /token 的特殊处理
    location /token {
        proxy_redirect off;
        proxy_ssl_server_name on;
        proxy_pass https://auth.docker.io;
        proxy_set_header Host auth.docker.io;
        proxy_set_header User-Agent $http_user_agent;
        proxy_set_header Accept $http_accept;
        proxy_set_header Accept-Language $http_accept_language;
        proxy_set_header Accept-Encoding $http_accept_encoding;
        proxy_set_header Connection "keep-alive";
        proxy_set_header Cache-Control "max-age=0";
        add_header 'Access-Control-Allow-Origin' '*';
    }
}

唯一有点缺陷的是拉取library下的需要补充上library

# nginx:latest  => library/nginx:latest
docker pull docker.xxxx.org/library/nginx:latest

其他非library下镜像

docker pull docker.xxxx.org/pengzhile/new-api:latest

其实也尝试用harbor做镜像缓存一直不成功,等个佬出个教程 :face_with_peeking_eye:

3 个赞


我那个只解决了拉镜像
登录还有push都没搞(因为没用过2333)

查水表警告