之前做私库的时候会在harbor中直接加入https证书,但是会占用80和443,如果再添加其它的虚拟主机比较麻烦,这里直接改为其它端口。
再通过物理机上的nginx去反向代理harbor(https)。
harbor修改步骤:
1、配置文件
[root@node1 harbor]# vim harbor.cfg ui_url_protocol = http 这里只用http,不像之前改为https
2、服务编排文件修改
[root@node1 harbor]# vim docker-compose.yml proxy: image: goharbor/nginx-photon:v1.7.4 container_name: nginx restart: always cap_drop: - ALL cap_add: - CHOWN - SETGID - SETUID - NET_BIND_SERVICE volumes: - ./common/config/nginx:/etc/nginx:z networks: - harbor dns_search: . ports: - 7080:80 # 80改掉 - 3443:443 # 443改掉 - 4443:4443
3、私库模板配置文件
[root@node1 harbor]# vim common/templates/registry/config.yml auth: token: issuer: harbor-token-issuer realm: $public_url:7080/service/token rootcertbundle: /etc/registry/root.crt service: harbor-registry
把 realm: $public_url/service/token 改为 realm: $public_url:7080/service/token
这个地方不改的话,会报错:
Error response from daemon: Get https://reg.xxx.com/v2/: unauthorized: authentication required
# 创建harbor
[root@node1 harbor]# sh install.sh #物理机配置nginx反向代理7080端口,加上https。 location / { proxy_pass http://127.0.0.1:7080; }
再docker login即可。
原创文章,转载请注明。本文链接地址: https://www.rootop.org/pages/4753.html