V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
glouhao
V2EX  ›  问与答

大佬们还在反代 docker 么,我这突然不能用了

  •  
  •   glouhao · 53 天前 · 394 次点击
    这是一个创建于 53 天前的主题,其中的信息可能已经有所发展或是发生改变。

    之前哪里抄的配置忘了,现在改成这里的: https://www.cnblogs.com/guangdelw/p/18253540 ,还是不管用,然后 AI 给我加了点,还是不行。

    server {
        listen      80;
        listen 443 ssl;
        server_name dk.xxxxx.com;
        index index.html index.htm;
        root  /data/www/blog/;
        add_header 'Access-Control-Allow-Origin' '*';
        add_header 'Access-Control-Allow-Headers' 'userTicket,ssotoken,token,Authorization,Content-Type,Accept,Origin,User-Agent,DNT,Cache-Control,X-Mx-ReqToken,X-Requested-With';
        add_header 'Access-Control-Allow-Credentials' 'true';
        add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
        send_timeout 600;
        client_header_buffer_size 128k;
        large_client_header_buffers 4 128k;
        proxy_buffer_size 64k;
        proxy_buffers 8 64k;
        ssl_certificate /etc/nginx/ssl/docker/fullchain.cer;
        ssl_certificate_key /etc/nginx/ssl/docker/xxxxx.com.key;
        
        # 处理 token 请求
        location /token {
            proxy_pass https://auth.docker.io/token;
            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;
            proxy_buffering off;
        }
    
        # 处理 v2 API 请求
        location /v2/ {
            proxy_pass https://registry-1.docker.io/v2/;
            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;
            proxy_intercept_errors on;
            recursive_error_pages on;
            error_page 301 302 307 = @handle_redirect;
        }
    
        # 处理其他请求
        location / {
            proxy_pass https://registry-1.docker.io;  
            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;
            proxy_intercept_errors on;
            recursive_error_pages on;
            error_page 301 302 307 = @handle_redirect;
        }
    
        location @handle_redirect {
            resolver 1.1.1.1;
            set $saved_redirect_location '$upstream_http_location';
            proxy_pass $saved_redirect_location;
        }
    
        access_log  /data/www/logs/nginx/docker.access.log;
        error_log  /data/www/logs/nginx/docker.error.log;
    }
    

    求大佬们帮忙指点下

    2 条回复
    YITWEI
        1
    YITWEI  
       52 天前 via iPhone
    location / {
    proxy_pass https://registry-1.docker.io;
    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;
    proxy_intercept_errors on;
    recursive_error_pages on;
    error_page 301 302 307 = @handle_redirect;

    }
    location @handle_redirect {
    resolver 1.1.1.1;
    set $saved_redirect_location '$upstream_http_location';
    proxy_pass $saved_redirect_location;
    }
    glouhao
        2
    glouhao  
    OP
       49 天前
    @YITWEI #1 谢谢刚看见,又找了个别人的抄了管用了
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   5620 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 03:25 · PVG 11:25 · LAX 19:25 · JFK 22:25
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.