时光沉淀

使用nginx反代 实现docker镜像加速

· Views · By 浪子

由于国内的公共加速倒了一大片,导致很多人为docker镜像无法拉取而烦恼

解决办法

使用境外vps反向代理

此处以宝塔为例

新建网站-输入域名 以 docker.ima.cm 为例
申请SSL证书,然后在伪静态设置中输入以下

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;
             }

保存即可.

然后把https://docker.ima.cm加入镜像加速列表

{
  "registry-mirrors": [
    "https://docker.ima.cm"
  ]
}

评论

0 条评论

暂无评论

Using $this when not in object context

Error: Using $this when not in object context in /app/data/plugins/FediverseSync/template/comment.php:3 Stack trace: #0 /app/data/plugins/FediverseSync/Plugin.php(989): require_once() #1 [internal function]: FediverseSync_Plugin::renderComments(Object(Widget\Archive), NULL) #2 /app/var/Typecho/Plugin.php(446): call_user_func_array(Array, Array) #3 /app/var/Widget/Archive.php(1274): Typecho\Plugin->__call('Widget_Archive:...', Array) #4 /app/data/themes/paper-main/footer.php(23): Widget\Archive->footer() #5 /app/var/Widget/Archive.php(1336): require('/app/data/theme...') #6 /app/data/themes/paper-main/post.php(51): Widget\Archive->need('footer.php') #7 /app/var/Widget/Archive.php(1418): require_once('/app/data/theme...') #8 /app/var/Typecho/Router.php(99): Widget\Archive->render() #9 /app/index.php(23): Typecho\Router::dispatch() #10 {main}