1.域名解析
用作反向代理的域名要提前解析,如果使用外国的DNS域名提供商的话,最好提前一天解析好。
2.配置NPM
2.1.Details选项卡
2.2.SSL选项卡
2.3.Advanced选项卡
location / {
# Docker hub 的官方镜像仓库
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;
# 对 upstream 状态码检查,实现 error_page 错误重定向
proxy_intercept_errors on;
recursive_error_pages on;
# 根据状态码执行对应操作,以下为381、302、387状态码都会触发
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;
}
3.测试
# 找一台机器进行测试
docker pull docker.youdomainname.top/library/busybox:latest
标签:redirect,set,hub,header,Nginx,manager,proxy,docker,location
From: https://www.cnblogs.com/monkey6/p/18280573