解析 HTTP 404 响应正文时出错:查找值开头的字符“<”无效 docker

error parsing HTTP 404 response body: invalid character '<' looking for beginning of value docker

我目前正在尝试将 nexus3 配置为 docker 图像的私有注册表,并将 nginx 作为反向代理。在 nexus 中创建了 3 个 repos,即 NexusDockerProxy(docker proxy), NexusDockerHosted(docker hosted,http port:4444) & NexusDockerGroup(docker group,http port:5555) with添加了托管和代理。

nexus 配置了 nginx,我们使用自签名证书并将其添加到 nginx 配置文件中。

server {

    proxy_send_timeout 120;
    proxy_read_timeout 300;
    proxy_buffering    off;
    tcp_nodelay        on;

    server_tokens off;
    client_max_body_size 1G;

    listen 80;
    server_name server908.int.org.com;
    location / {
          rewrite ^(.*) https://server908.int.org.com permanent;
    }
}

server {

    listen 443;
    server_name server908.int.org.com;
    keepalive_timeout 60;
    ssl on;
    ssl_certificate /etc/ssl/certs/orgnexus.crt;
    ssl_certificate_key /etc/ssl/certs/orgnexus.key;
    ssl_ciphers HIGH:!kEDH:!ADH:!MD5:@STRENGTH;
    ssl_session_cache shared:TLSSSL:16m;
    ssl_session_timeout 10m;
    ssl_prefer_server_ciphers on;

    location / {

      proxy_set_header        Host $http_host;
      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 "https";
      proxy_pass              http://server908.int.org.com:8082;
      proxy_read_timeout      90;

    }
}

# correlates to your nexus http connector
server {

    listen 6666;
    server_name server908.int.org.com;
    keepalive_timeout 60;
    ssl on;
    ssl_certificate /etc/ssl/certs/orgnexus.crt;
    ssl_certificate_key /etc/ssl/certs/orgnexus.key;
    ssl_ciphers HIGH:!kEDH:!ADH:!MD5:@STRENGTH;
    ssl_session_cache shared:TLSSSL:16m;
    ssl_session_timeout 10m;
    ssl_prefer_server_ciphers on;
    client_max_body_size 1G;
    chunked_transfer_encoding on;

    location / {

      access_log              /var/log/nginx/docker.log;
      proxy_set_header        Host $http_host;
      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 "https";
      proxy_pass              http://server908.int.org.com:5555;
      proxy_read_timeout      90;

    }
}

我们在下面的条目中添加了“/etc/default/docker”文件。

http_proxy=http://x.x.x.x:3128
https_proxy=http://x.x.x.x:3128

登录也成功

[root@server446 ~]$ docker login -u admin -p admin123 server908.int.org.com:6666
Login Succeeded

搜索和拉取图片也能正常工作。

[test@server446 ~]$ docker search server908.int.org.com:6666/mac
INDEX      NAME                                                                 DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
org.com   server908.int.org.com:6666/crate                                    CrateDB is a distributed SQL database hand...   79        [OK]
org.com   server908.int.org.com:6666/maccam912/meanjs                         MEANJS (not MEANIO) starting point for dev...   27                   [OK]
org.com   server908.int.org.com:6666/macadmins/puppetmaster                   Simple puppetmaster based on CentOS 6           25                   [OK]
org.com   server908.int.org.com:6666/macadmins/bsdpy                          Apple NetBoot replacement written in Pytho...   18                   [OK]
org.com   server908.int.org.com:6666/macadmins/reposado                       Host Apple Software Updates from a Docker ...   12                   [OK]
org.com   server908.int.org.com:6666/mackerel/mackerel-agent                                                                  11                   [OK]
org.com   server908.int.org.com:6666/macadmins/munkiwebadmin                  This Docker container runs MunkiWebAdmin. ...   8                    [OK]
org.com   server908.int.org.com:6666/macadmins/postgres                       Postgres that accepts remote connections b...   8                    [OK]
org.com   server908.int.org.com:6666/macropin/strider                         Possibly the best `Dockerfile` for Strider-CD   8                    [OK]
org.com   server908.int.org.com:6666/mace/openvpn-as                          OpenVPN Access-Server with WebUI                7                    [OK]
org.com   server908.int.org.com:6666/frolvlad/alpine-python-machinelearning   Small Docker image with Python Machine Lea...   6                    [OK]
org.com   server908.int.org.com:6666/macadmins/munkireport-php                Docker autobuild repository for https://re...   6                    [OK]
org.com   server908.int.org.com:6666/mace/qbittorrent                         qBittorrent build from source                   6                    [OK]
org.com   server908.int.org.com:6666/macropin/sshd                            (deprecated) Use docker.io/panubo/sshd          5                    [OK]
org.com   server908.int.org.com:6666/macadmins/macnamer                                                                       4                    [OK]
org.com   server908.int.org.com:6666/macadmins/puppetmaster-whdcli            Puppetmaster + WHDCLI for autosigning base...   4                    [OK]
org.com   server908.int.org.com:6666/macadmins/sal                            An image that runs [Sal](https://github.co...   4                    [OK]
org.com   server908.int.org.com:6666/macropin/roundcube                       Docker container for Roundcube webmail          4                    [OK]
org.com   server908.int.org.com:6666/uetchy/machinelearning                   Dockerfile for scientists studying Machine...   4                    [OK]
org.com   server908.int.org.com:6666/clearlinux/machine-learning              Machine Learning Container                      3                    [OK]
org.com   server908.int.org.com:6666/hartator/wayback-machine-downloader      Download an entire archive from the Waybac...   3                    [OK]
org.com   server908.int.org.com:6666/macadmins/whd                            Docker container for SolarWinds WebHelpDesk     3                    [OK]
org.com   server908.int.org.com:6666/macinv/gunicorn-example                  A simple Gunicorn example                       2                    [OK]
org.com   server908.int.org.com:6666/macropin/mailman                         Mailman all in one container                    2                    [OK]
org.com   server908.int.org.com:6666/spacemacs/emacs25                        Spacemacs running on Emacs 25.                  2                    [OK]

[test@server446 ~]$ docker pull server908.int.org.com:6666/macadmins/puppetmaster
Using default tag: latest
Trying to pull repository server908.int.org.com:6666/macadmins/puppetmaster ...
sha256:bf7a53a0ddb6cd0371cfec3fe6131347b5a3712c2cf282400c979ed254a38f67: Pulling from server908.int.org.com:6666/macadmins/puppetmaster
0d399614d56a: Pull complete
75e4c6031170: Pull complete
12a00ed15a39: Pull complete
6fb754ec65e3: Pull complete
9b6cf7664f02: Pull complete
07db30a930a5: Pull complete
ccdd2cf9b303: Pull complete
820dfdfc6db7: Pull complete
78c5dec8ba5d: Pull complete
Digest: sha256:bf7a53a0ddb6cd0371cfec3fe6131347b5a3712c2cf282400c979ed254a38f67
Status: Downloaded newer image for server908.int.org.com:6666/macadmins/puppetmaster:latest

但是在推送图像时,我们得到如下 404 错误。

[test@server446 ~]$ docker push server908.int.org.com:6666/maven:1
The push refers to a repository [server908.int.org.com:6666/maven]
701925f78142: Layer already exists
78bb4fee972f: Layer already exists
e1300844f726: Layer already exists
bfee0515af91: Preparing
2afcf4c557eb: Preparing
72cfa243711c: Waiting
9bf603e17b04: Waiting
70b22baddf90: Waiting
596ecbaf3ba4: Waiting
445ed6ee6867: Waiting
c59fa6cbcbd9: Waiting
8d4d1ab5ff74: Waiting
error parsing HTTP 404 response body: invalid character '<' looking for beginning of value:

我真的很想让它工作,但现在坚持最后一步。任何帮助 docker 推动工作的帮助都将非常有帮助,谢谢。

它正在工作。使用不同的代理端口配置服务器端口 6666 块。对于 GET 请求,代理端口应为 5555(即 docker-proxy repo)端口,GET 代理端口以外的端口应为 4444(即 docker-hosted repo)端口

评论了“/etc/default/docker”文件中的代理条目。

重启 Nginx。

执行登录

Post登录一个文件名"config.json"将在“.docker”目录下创建

在 docker 中心搜索可用的图像。 通过 Nexus 代理从 docker 集线器中拉取图像 标记拉取的图像 推送图片

从 Nexus Repo 拉取(这应该比从 docker hub 拉取快) 还要确保在 Nexus SSL Certificate Section 中添加代理服务器证书。

keytool -J-Dhttps.proxyHost=<proxy_hostname> -J-Dhttps.proxyPort=<proxy_port> -printcert -rfc -sslserver <remote_host_name:remote_ssl_port>

将 和 替换为 Nexus 在管理 -> 服务器下配置的 HTTP 代理服务器。替换为存在认证问题的远程主机和端口之一。端口默认443可以省略。

您应该看到至少有两个由上述命令打印的条目。将最后打印的证书内容全部复制到剪贴板。这应该是您的代理服务器的证书,添加到证书链的末尾。

复制的证书内容应以 -----BEGIN CERTIFICATE----- 开头,以 -----END CERTIFICATE----- 结尾。

然后在 Nexus UI 中,转到管理 -> SSL 证书并单击添加...,然后选择粘贴 PEM。将证书内容粘贴到打开的对话框中。

单击加载证书。在接下来的 window 中验证证书内容。验证列出的颁发者详细信息来自您的代理服务器证书。满意后单击添加证书。


希望对您有所帮助。

错误 error parsing HTTP 404 response body... 是 nexus 的典型错误,它试图告诉您您正在推送到组或代理存储库,而您只能推送到托管存储库。

据我所知,这个解释可能适合:

nginx 配置为

server {
    listen 6666;
    server_name server908.int.org.com;
...
        proxy_pass              http://server908.int.org.com:5555;
        proxy_read_timeout      90;
...
}

你推送到这个代理:

docker push server908.int.org.com:6666/maven:1

你最终会推到 server908.int.org.com:5555。

以上 Nexus 配置为

Created 3 repos within nexus namely NexusDockerProxy(docker proxy), NexusDockerHosted(docker hosted,http port:4444) & NexusDockerGroup(docker group,http port:5555) with both the hosted and proxy added

您正在推送到 Docker 组。我认为这就是它抛出上述错误的原因。

将您的 nginx-proxy 配置为转发到 4444 而不是 5555,您应该可以推送。

旁注: 这使得有必要有两个端点(一个用于 "reading from the group")和一个用于推送到 Nexus。

因此,在您的 nginx 配置中设置两个端点(一个代理到 5555,一个代理 4444)。在所有 Docker 文件中以及从注册表中提取时使用 4444 代理。仅在推送时使用代理到 ​​5555。

所以我建议这样的事情可能会成功:

# Proxy 1, the "pull" proxy. Use this when pulling and in your Dockerfiles/docker-compose files
server {

    listen 6666;
    server_name server908.int.org.com;
    [...ssl config and everything else...]

    location / {

        access_log              /var/log/nginx/docker-pull.log;
        [...header config and other things...]
        proxy_pass              http://server908.int.org.com:5555;
        proxy_read_timeout      90;
    }
}

# Proxy 2, the "push" proxy. Use this endpoint ONLY when pushing images to Nexus.
server {

    listen 7777;
    server_name server908.int.org.com;

    [...ssl config and everything else...]

    location / {

        access_log              /var/log/nginx/docker-push.log;
        [...header config and other things...]
        proxy_pass              http://server908.int.org.com:4444;
        proxy_read_timeout      90;
    }
}

现在我不是 Nexus 专家,但这应该可以解决您的问题。我不确定 Nexus 是否打算通过一个端点(通过一个端口组和托管 Docker 回购)工作,但我记得在当天使用这两个端点设置它,一个用于推送一个用于拉取.

希望对您有所帮助!