Nginx 配置 docker 镜像代理服务,解决docker pull问题
温馨提示:
本文最后更新于 2024年06月16日,已超过 290 天没有更新。若文章内的图片失效(无法正常加载),请留言反馈或直接联系我。
话不多说,下面是NGINX的配置:
server {
listen 6333 ssl http2;
listen [::]:6333 ssl http2;
server_name xxxx;
index index.php index.html index.htm default.php default.htm default.html;
ssl_certificate fullchain.pem;
ssl_certificate_key privkey.pem;
ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3;
ssl_ciphers EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
add_header Strict-Transport-Security "max-age=31536000";
error_page 497 https://$host$request_uri;
location / {
proxy_pass https://registry-1.docker.io; # Docker Hub 的官方镜像仓库
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;
# 对 upstream 状态码检查,实现 error_page 错误重定向
proxy_intercept_errors on;
recursive_error_pages on;
# 错误处理和重定向逻辑
error_page 301 302 307 = @handle_redirect;
error_page 429 = @handle_too_many_requests;
}
location @handle_redirect {
resolver 1.1.1.1;
set $saved_redirect_location '$upstream_http_location';
proxy_pass $saved_redirect_location;
}
location @handle_too_many_requests {
return 429 "Too many requests, please try again later.";
}
access_log /www/wwwlogs/xianxian0827-6333.cloud.log;
error_log /www/wwwlogs/xianxian0827-6333.cloud.error.log;
}
"registry-mirrors": [
"https://ip:6333"
]
正文到此结束
- 本文标签: Linux
- 本文链接: https://blog.sandy1029.cloud/article/7
- 版权声明: 本文由nisan原创发布,转载请遵循《署名-非商业性使用-相同方式共享 4.0 国际 (CC BY-NC-SA 4.0)》许可协议授权