我在nginx中有如下配置
upstream artifactory_lb {
server artifactoryserver.com:8081;
server otherartifactoryserver.com:8081 backup;
}
其他配置
rewrite ^/(v1|v2)/(.*) /api/docker/image-repo/$1/$2;
client_max_body_size 0;
chunked_transfer_encoding on;
location /v1 {
allow all;
proxy_read_timeout 900;
proxy_pass_header Server;
proxy_cookie_path ~*^/.* /;
proxy_set_header X-Artifactory-Override-Base-Url $http_x_forwarded_proto://$host;
proxy_set_header X-Forwarded-Port $server_port;
proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://artifactory_lb;
}
当我尝试推送图像时,docker 客户端出现 405 - Not allowed 错误,而 nginx 日志显示以下错误
/usr/share/nginx/html/api/docker/image-repo/v1/_ping" failed (2: No such file or directory)
如何配置 nginx 以便它 ping 正确的 repo 位置?是因为上游服务器没有repo吗?
更新: 进行以下更改后
location /v1 --> location /
proxy_pass http://artifactoryserver.com:8081/artifactory/
此错误消失,但我在 docker 客户端上收到以下错误
Sending image list
Error: Status 403 trying to push repository ubuntu: "{\"error\": \"Unauthorized updating repository images\"}"
docker 守护进程日志显示
POST /v1.21/images/host:port/ubuntu/push?tag=
这是否意味着它正在访问存储库并需要推送图像的权限,或者这是否意味着存储库不存在??
最佳答案
未授权的错误是因为客户端的docker版本不支持artifactory配置的v1 api
关于http - nginx 没有那个文件或目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34423758/