harbor反代后客户端无法登录

环境描述

部署harbor后开启https,使用apisix反代到ip:port

问题

1
2
3
4
[root@xxx ~]# docker login https://harbor.xxx.com/
Username: admin
Password: 
Error response from daemon: Get "https://harbor.xxx.com/v2/": Get "https://harbor.xxx.com:44443/service/token?account=admin&client_id=docker&offline_token=true&service=harbor-registry": net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers) (Client.Timeout exceeded while awaiting headers)

分析

着重看报错中的https://harbor.xxx.com:44443,44443为harbor.yaml中设置的https端口。该问题修改配置应该可解决

解决

停止harbor

1
docker-compose down -v

修改harbor.yml配置文件,取消external_url注释,设置为https://harbor.xxx.com

1
2
3
# Uncomment external_url if you want to enable external proxy
# And when it enabled the hostname will no longer used
external_url: https://harbor.xxx.com

生成配置

1
./prepare --with-notary --with-trivy --with-chartmuseum

启动harbor

1
docker-compose up -d
updatedupdated2024-10-282024-10-28