我尝试在nginx反向代理后面设置nexus docker存储库(使用自签名SSL证书(。我使用这个官方的docker-compos文件:
https://github.com/sonatype-nexus-community/docker-nginx-nexus-repository
安装 docker-compose 后,我最终能够启动两个容器:nexus3 和 nginx with./nexus.sh
。我花了几次尝试,因为我不得不将 nexus pasword 更改为admin123
并在docker-nginx-nexus-repository_nexus-repository_1
容器内添加nexus.scripts.allowCreation=true
(/nexus-data/etc/nexus.properties
(,否则curl -v -u admin:admin123 --insecure --header 'Content-Type: application/json' 'https://localhost/service/rest/v1/script' -d @nexus-repository/create-docker-proxy.json
会失败。最后,我与 http 端口 5000 上的 docker-proxy 存储库建立了联系,指向 DockerHub 上。
此外,在主机上,我添加了:
cat /etc/docker/daemon.json
{
"insecure-registries": ["10.97.7.95:5000"]
}
和:
cat /etc/systemd/system/docker.service.d/http-proxy.conf
[Service]
Environment="HTTPS_PROXY=https://10.97.7.95:5000/"
并重新启动了码头工人。
但是,一旦我尝试在主机上拉取一些图像,就会出现以下错误:
# docker pull 10.97.7.95:5000/hello-world
Using default tag: latest
Error response from daemon: error parsing HTTP 400 response body: invalid character '<' looking for beginning of value: "<html>rn<head><title>400 The plain HTTP request was sent to HTTPS port</title></head>rn<body>rn<center><h1>400 Bad Request</h1></center>rn<center>The plain HTTP request was sent to HTTPS port</center>rn<hr><center>nginx/1.19.0</center>rn</body>rn</html>rn"
docker logs -f docker-nginx-nexus-repository_nginx-proxy_1
显示:
172.18.0.1 - - [05/Jul/2020:16:21:08 +0000] "CONNECT 10.97.7.95:5000 HTTP/1.1" 400 157 "-" "-"
172.18.0.1 - - [05/Jul/2020:16:21:08 +0000] "GET /v2/ HTTP/1.1" 400 255 "-" "docker/19.03.8 go/go1.12.17 git-commit/afacb8b7f0 kernel/4.19.0-6-amd64 os/linux arch/amd64 UpstreamClient(Docker-Client/19.03.8 x5C(linuxx5C))"
172.18.0.1 - - [05/Jul/2020:16:21:08 +0000] "GET /v2/hello-world/manifests/latest HTTP/1.1" 400 255 "-" "docker/19.03.8 go/go1.12.17 git-commit/afacb8b7f0 kernel/4.19.0-6-amd64 os/linux arch/amd64 UpstreamClient(Docker-Client/19.03.8 x5C(linuxx5C))"
也:
# docker login 10.97.7.95:5000
Username: admin
Password:
Error response from daemon: login attempt to http://10.97.7.95:5000/v2/ failed with status: 400 Bad Request
我错过了什么?
你自己的docker-repository正在使用nginx的反向代理设置运行。如果您没有从您发布的 Github 存储库更改 nginx.conf,则启用了 ssl。它在第 25 行说:
ssl on;
nginx 将响应 HTTP 400 - 错误请求,如果您尝试使用纯 HTTP 访问 HTTPS 端点。