nginx 没有那个文件或目录

nginx no such file or directory

我在nginx中有如下配置

upstream artifactory_lb {
    server artifactoryserver.com:8081;
    server otherartifactoryserver.com:8081 backup;
}

其他配置

rewrite ^/(v1|v2)/(.*) /api/docker/image-repo//;
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=

这是否意味着它正在访问 repo 并需要推送图像的权限,或者这是否意味着 repo 不存在??

未经授权的错误是由于客户端的 docker 版本不支持 artifactory 配置为

的 v1 api