Docker 不会通过 HTTP 发送身份验证 headers

Docker will not send auth headers over HTTP

我正在设置一个私人 docker 注册表,前面使用 NGINX 进行身份验证。两者都在一个链接的容器中。我使用的 nginx 镜像是 jwilder/nginx-proxy。我可以正常 ping 注册表:

>http zite.com:5000/v1/_ping
HTTP/1.1 200 OK
Cache-Control: no-cache
Connection: keep-alive
Content-Length: 2
Content-Type: application/json
Date: Thu, 02 Apr 2015 12:13:32 GMT
Expires: -1
Pragma: no-cache
Server: nginx/1.7.11
X-Docker-Registry-Standalone: True

但是推送图像给了我:

FATA[0001] HTTP code 401, Docker will not send auth headers over HTTP

我尝试将注册表标记为不安全但无济于事:

--insecure-registry zite.com:5000

我已经能够在中间没有 NGINX 的情况下获得此设置 运行。

我的 NGINX 配置文件是(其中 'dockerregistry' 是链接容器的名称):

upstream dockerregistry {
    server dockerregistry:5000;
}

server {
  listen 80;
  server_name zite.com;
  proxy_set_header Host $http_host;
  client_max_body_size 0;
  location / {
    proxy_pass http://dockerregistry;
    auth_basic "Docker Registry";
    auth_basic_user_file /etc/nginx/dockerregistry_users;
  }
  location /v1/_ping {
    auth_basic off;
    proxy_pass http://dockerregistry;
  }
}

我想我已经阅读了几乎所有关于此设置的文章,但我无法弄清楚的是 HTTP 仅访问私有 docker 存储库是否根本就是 no-go。有可能让它工作吗?或者我必须使用 SSL 证书吗?如果是这样,谁知道此设置的好指南?

是的,如果您想对您的注册表使用(基本)身份验证(没有办法解决),您需要 SSL。

这是一个经过深思熟虑的设计决定:原因是通过纯 http 的基本身份验证会给人一种错误的安全感,而凭据实际上会以明文形式传输并且极易受到攻击。

不允许虚假安全确实是故意的(尽管这是一个有问题的举动,从被其混淆的人数来看)。

关于设置 SSL,我会使用 repo 中的示例 nginx 文件: https://github.com/docker/docker-registry/tree/master/contrib/nginx