zoukankan      html  css  js  c++  java
  • Harbor配合Nginx配置公网域名

    需求:

          公司内部将制作的docker镜像推送到公司私有Harbor仓库,客户可以通过公网域名直接拉取公司Harbor公开项目下的镜像,通过分配的Harbor用户名密码可以拉取对应的私有项目下的镜像。 

    安装Harbor:

         参考这篇博文:https://www.cnblogs.com/zhangmingcheng/p/12753959.html

    Harbor配置nginx代理:

          Harbor默认只能使用harbor.yml中hostname指定的ip或主机名作为web访问地址,但在实际使用过程中,一般不允许ip地址或者主机名直接暴露在外访问,故需要配置nginx代理,通过代理后指定的地址进行访问。

    • 通过nginx为harbor后端暴露的地址及端口设置proxy地址,来源于harbor配置文件中的hostname及port
    • 修改harbor配置文件再次使用nginx设置的proxy地址

          通过修改nginx的配置文件中server模块设置代理地址以及端口等信息,若harbor与nginx不在同一个服务器上或harbor不止一个服务器,还需要通过nginx的upstream模块来实现请求后端realserver及负载均衡,nginx配置文件修改处示例如下:   

    Harbor设置:

         通过nginx配置了代理之后,还需要修改harbor的配置文件设置proxy地址:

         vim harbor.yml

     web验证:

    通过浏览器访问http://xx.xx.com:port访问代理后地址

    客户阿里云服务器测试:

    1、直接拉取public项目下的镜像:

     2、拉取私有项目下的镜像

    遇到的问题:

    1、request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)错误:

    [root@iZrj9j76z8dlull9vqa4tqZ ~]# docker pull harbor.xxx.cn:443/1-1/mytomcat:8.5.52
    Error response from daemon: Head https://harbor.xxx.cn:443/v2/1-1/mytomcat/manifests/8.5.52: Get http://10.20.31.104:5000/service/token?scope=repository%3A1-1%2Fmytomcat%3Apull&service=harbor-registry: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)

    解决方案:修改harbor.yml配置文件,取消external_url注释,设置为:external_url: https://harbor.xxx.cn,注意https://harbor.xxx.cn后面不能写端口。

    然后,docker-compose down停止所有服务,删除当前配置目录:rm -rf ./common/config下配置清单,重新执行install.sh生成配置,即可解决

    2、dial tcp: lookup harbor.xxx.cn;: no such host错误:

    解决方案:修改harbor.yml配置文件,hostname字段只写harbor.xxx.cn,域名前面不要写http/https协议。

    3、Harbor重启失败,报ERROR: for harbor-portal Cannot start service portal: failed to initialize logging driver: dial tcp 127.0.0.1:1514: connect: connection refused错误

    解决方案:https://blog.csdn.net/qq_39680564/article/details/107237110

    注意:只要修改了harbor.yml,要想让配置生效,需要删除当前配置目录:rm -rf ./common/config下配置清单,重新执行install.sh生成配置。

    参考:https://blog.csdn.net/lcl_xiaowugui/article/details/105422794

    参考:https://blog.csdn.net/fengchao169/article/details/106223253/

    参考:https://www.cnblogs.com/liucx/p/12981023.html

    参考:https://blog.csdn.net/qq_39680564/article/details/107237110

  • 相关阅读:
    js,h5页面判断客户端是ios还是安卓
    jQuery中没有innerHtml和innerText
    一个导航动画
    o'Reill的SVG精髓(第二版)学习笔记——第十二章
    o'Reill的SVG精髓(第二版)学习笔记——第十一章
    o'Reill的SVG精髓(第二版)学习笔记——第十章
    o'Reill的SVG精髓(第二版)学习笔记——第九章
    o'Reill的SVG精髓(第二版)学习笔记——第八章
    o'Reill的SVG精髓(第二版)学习笔记——第七章
    原生html、js手写 radio与checkbox 美化
  • 原文地址:https://www.cnblogs.com/zhangmingcheng/p/14167615.html
Copyright © 2011-2022 走看看