当前位置: 首页 > 面试题库 >

Nginx代理后面的Docker私有注册表(v2)格式不正确的HTTP响应

万俟丁雷
2023-03-14
问题内容

我已经按照其官方文档在CentOS
7盒子上设置了Docker私有注册表(v2):https :
//docs.docker.com/registry/deploying/

我在Fedora 21机器上运行docker 1.6.0。

注册表在端口5000上运行,并使用由受信任的CA签名的SSL密钥。我将docker-
registry.example.com的DNS记录设置为服务器的内部IP。运行’docker pull docker-
registry.example.com:5000/tag/image’,它可以正常工作。

我设置了一个运行nginx版本的nginx服务器:nginx / 1.8.0,并为指向nginx服务器的“ nginx-
proxy.example.com”设置了dns记录,并设置了一个站点。这是配置:

server {
   listen 443 ssl;
   server_name nginx-proxy.example.com;

   add_header Docker-Distribution-Api-Version: registry/2.0 always;

   ssl on;
   ssl_certificate /etc/ssl/certs/cert.crt;
   ssl_certificate_key /etc/ssl/certs/key.key;

   proxy_set_header Host $host;
   proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
   proxy_set_header X-Real-IP $remote_addr;
   proxy_set_header X-Forwarded-Proto $scheme;
   proxy_set_header X-Original-URI $request_uri;
   proxy_set_header Docker-Distribution-Api-Version registry/2.0;

   location / {
     proxy_pass http://docker-registry.example.com:5000;
   }
}

当我尝试运行’docker pull nginx-proxy.example.com/tag/image’时,出现以下错误:

FATA[0001] Error response from daemon: v1 ping attempt failed with error: Get https://nginx-proxy.example.com/v1/_ping: malformed HTTP response "\x15\x03\x01\x00\x02\x02"

我的问题是双重的。

  1. 为什么Docker客户端正在寻找/ v1_ / ping?
  2. 为什么我看到“格式错误的http响应”

如果运行“ curl -v nginx-proxy.example.com/v2”,则会看到:

[root@alex amerenda] $ curl -v https://nginx-proxy.example.com/v2/
* Hostname was NOT found in DNS cache
*   Trying 10.1.43.165...
* Connected to nginx-proxy.example.com (10.1.43.165) port 443 (#0)
* Initializing NSS with certpath: sql:/etc/pki/nssdb
*   CAfile: /etc/pki/tls/certs/ca-bundle.crt
  CApath: none
* SSL connection using TLS_DHE_RSA_WITH_AES_128_GCM_SHA256
* Server certificate:
*   subject: CN=*.example.com,O="example, Inc.",L=New York,ST=New York,C=US
*   start date: Sep 15 00:00:00 2014 GMT
*   expire date: Sep 15 23:59:59 2015 GMT
*   common name: *.example.com
*   issuer: CN=GeoTrust SSL CA - G2,O=GeoTrust Inc.,C=US
> GET /v2/ HTTP/1.1
> User-Agent: curl/7.37.0
> Host: nginx-proxy.example.com
> Accept: */*
> \x15\x03\x01\x00\x02\x02

如果我执行“ curl -v docker-registry.example.com”,则会收到200
OK响应。因此,nginx必须对此负责。有谁知道为什么会这样?它让我发疯!


问题答案:
 proxy_pass http://docker-registry.example.com:5000;

您正在通过纯HTTP传递请求(即没有https)

\ x15 \ x03 \ x01 \ x00 \ x02 \ x02

您将获得一个SSL响应。因此,看起来您必须使用https://而不是http://来访问端口5000。您甚至还知道您正在使用SSL:

注册表在端口5000上运行,并使用由受信任的CA签名的SSL密钥。

除此之外:请使用为example.com之类的示例保留的名称,并且在示例中不要使用不属于您的域名。



 类似资料:
  • 我在CentOS 7框上设置了Docker私有注册表(v2),下面是他们的官方留档:https://docs.docker.com/registry/deploying/ 我在Fedora 21盒子上运行docker 1.6.0。 注册表正在端口5000上运行,并且正在使用一个由可信CA签名的SSL密钥。我为“docker注册表”设置了一个DNS记录。实例com'是服务器的内部IP。运行“dock

  • 问题内容: 我创建了两个Docker容器。第一个提供专用的Docker注册表,第二个提供官方Docker注册表的镜像: 现在,我想将两者结合起来。每当用户 提取 图像时,都应首先查询私有注册表,然后查询镜像。当图像被 推送时, 它们仅应被推送到私有注册表。 我不知道如何做到这一点。任何帮助表示赞赏。 问题答案: 您不能仅仅强制所有 docker push 命令推送到您的私有注册表。原因之一是您可以

  • 我正在尝试将一个图像推送到我的docker私有存储库: Docker告诉我: push引用存储库[living-registry.com:5000/busybox]Get https://living-registry.com:5000/v1/_ping:read tcp 195.83.122.16:39714->195.83.122.16:5000:read:对等体重置连接 这些命令正在Core

  • 我从AWS控制台创建了一个EC2实例,通过安全组选项打开HTTP端口(例如8080) 我创建了一个新的负载均衡器,使用HTTPS将其连接到实例的HTTP端口。 我使用此配置创建了文件(我使用verdaccio作为npm私有注册表,使用registry:2作为docker注册表: 现在,注册表运行良好。因此,如果访问,我就可以看到它,并且可以通过将npm包推送到它 然而,关于docker注册表,虽然

  • 我们正在使用confluent platform 5.3.1社区版。 最近,作为安全扫描的一部分,我们发现Kafka rest代理和架构注册表服务缺少http头(X-XSS-Protection,X-Content-Type-Options)安全漏洞。 根据汇合留档,我们可以在配置中添加response.http.headers.config属性来添加/设置所需的标头。 https://docs.

  • 问题内容: 我已经在一个docker容器中运行了一个gitlab服务器,并在另一个docker容器中运行了一个外部nginx服务器,因此gitlab nginx服务器被停用了。现在我想使用gitlab服务器中包含的docker注册表。 我尝试从管理手册中获取信息:https : //docs.gitlab.com/ee/administration/container_registry.html