我搭建了一個docker私有倉庫,
1、系統是centos6
2、通過nginx 代理,并增加了用戶名和密碼認證,還有ssl加密傳輸
3、docker倉庫registry是安裝在192.168.0.40上,并且nginx也是安裝在這臺主機上
nginx配置如下:
server {
listen 443;
server_name registry.info.cn;
ssl on;
ssl_certificate info.cn.crt;
ssl_certificate_key info.cn.key;
access_log logs/host.access.log main;
location / {
auth_basic "Security Zones";
auth_basic_user_file /usr/local/nginx/password;
proxy_pass http://192.168.0.40:5000;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
其中ca證書是花錢購買的,能正常使用。
在docker客戶端通過
curl -X GET https://test:[email protected]/v1/search 能正確回傳
docker login https://registry.info.cn 可以正常登錄,能回傳success
但是我push一個images到registry的時候就報錯
[root@localhost /]# docker push registry.info.cn/centos7
The push refers to a repository [registry.info.cn/centos7] (len: 1)
Sending image list
Pushing repository registry.info.cn/centos7 (1 tags)
47d44cb6f252: Pushing
Failed to upload metadata: Put https://192.168.0.40:5000/v1/ima ... 8f92557f4d05a/json: EOF
我這里好奇的是,push的時候怎么又會決議出IP來訪問了,https://192.168.0.40:5000這個肯定是會出錯的,不知道原因?????
uj5u.com熱心網友回復:
問題已解決,是nginx的配置問題,默認反向代理服務器會向后端真實服務器發送請求,并且請求頭中的host欄位應為proxy_pass指令設定的服務器。所以只要在nginx的location里增加如下配置即可,作用是不修改web請求header中的host欄位。
proxy_set_header Host $http_host;
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/85912.html
標籤:Docker
