簡體   English   中英

nginx 反向代理后面的 Nexus docker 存儲庫

[英]Nexus docker repository behind nginx reverse-proxy

我嘗試在 nginx 反向代理(帶有自簽名 SSL 證書)后面設置 nexus docker 存儲庫。 我使用這個官方的 docker-compose 文件:

https://github.com/sonatype-nexus-community/docker-nginx-nexus-repository

安裝 docker-compose 后,我最終能夠使用 ./nexus.sh 啟動兩個容器:nexus3 和./nexus.sh 我花了幾次嘗試,因為我必須將 nexus 密碼更改為admin123並在 docker docker-nginx-nexus-repository_nexus-repository_1容器(在/nexus-data/etc/nexus.properties中)中添加nexus.scripts.allowCreation=true否則curl -v -u admin:admin123 --insecure --header 'Content-Type: application/json' 'https://localhost/service/rest/v1/script' -d @nexus-repository/create-docker-proxy.json會失敗。 最后,我在指向 DockerHub 的 http 端口 5000 上與 docker-proxy 存儲庫建立了聯系。

此外,在我添加的主機上:

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。

但是,一旦我嘗試在主機上提取一些圖像,就會出現以下錯誤:

# 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>\r\n<head><title>400 The plain HTTP request was sent to HTTPS port</title></head>\r\n<body>\r\n<center><h1>400 Bad Request</h1></center>\r\n<center>The plain HTTP request was sent to HTTPS port</center>\r\n<hr><center>nginx/1.19.0</center>\r\n</body>\r\n</html>\r\n"

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(linux\x5C))"
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(linux\x5C))"

還:

# 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 - 如果您嘗試使用普通 Z2893C9EA246ZF7 訪問 HTTPS 端點,則會出現錯誤請求。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM