Sonatype Nexus3 搭建私有仓库

2022/12/2 5:25:17

本文主要是介绍Sonatype Nexus3 搭建私有仓库,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

Nexus是Sonatype提供的仓库管理平台,Nuexus Repository OSS3能够支持Maven、npm、Docker、YUM、Helm等格式数据的存储和发布;并且能够与Jekins、SonaQube和Eclipse等工具进行集成。
Nexus支持作为宿主和代理存储库的本地Maven/Docker存储库,可以直接将这些存储库暴露给客户端工具;也可以以存储库组的方式暴露给客户端工具,存储库组是合并了多个存储库的内容的存储库,能够通过一个URL将多个存储库暴露给客户端工具,从而便于用户的使用。通过nexus自建能够有效减少访问获取镜像的时间和对带宽使用,并能够通过自有的镜像仓库共享企业自己的镜像。

SSL证书

需要 2 个域名,一个用来代理 Nexus管理面板,另一个用做 docker仓库,docker需要单独的端口

Nexus 前台:registry.jonty.top

Docker 仓库:hub.jonty.top

自签名证书

我们通过Nginx代理Nexus服务,需要先生成自签名的SSL证书,通过内部DNS域名访问(无需在docker pull的时候还要带一个端口)

使用一键生成工具:两个域名都要签发证书

# 克隆仓库 git clone https://github.com/Fishdrowned/ssl.git cd ssl # 根据你的域名更改 /bin/bash ./gen.cert.sh hub.jonty.top

PS:如果是打算做外网仓库服务,可以直接申请一个免费的SSL证书(云厂商都提供),本文使用内网域名,使用自签名证


 
[root@nexus3 ssl-master]# ls ca.cnf docs flush.sh gen.cert.sh gen.root.sh LICENSE out README.md [root@nexus3 ssl-master]# cd out/ [root@nexus3 out]# ls cert.key.pem index.txt index.txt.attr index.txt.attr.old index.txt.old newcerts root.crt root.key.pem serial serial.old [root@nexus3 out]# cd .. [root@nexus3 ssl-master]# /bin/bash gen.cert.sh hub.jonty.top # 换成你的域名 Using configuration from ./ca.cnf Check that the request matches the signature Signature ok The Subject's Distinguished Name is as follows countryName :PRINTABLE:'CN' stateOrProvinceName :ASN.1 12:'Guangdong' localityName :ASN.1 12:'Guangzhou' organizationName :ASN.1 12:'Fishdrowned' organizationalUnitName:ASN.1 12:'hub.jonty.top' commonName :ASN.1 12:'*.hub.jonty.top' Certificate is to be certified until Jul 11 08:06:41 2024 GMT (730 days) Write out database with 1 new entries Data Base Updated Certificates are located in: lrwxrwxrwx. 1 root root 44 Jul 12 16:06 /root/docker/ssl-master/out/hub.jonty.top/hub.xxx.bundle.crt -> ./20220712-1606/hub.jonty.top.bundle.crt lrwxrwxrwx. 1 root root 37 Jul 12 16:06 /root/docker/ssl-master/out/hub.jonty.top/hub.xxx.crt -> ./20220712-1606/hub.jonty.top.crt lrwxrwxrwx. 1 root root 15 Jul 12 16:06 /root/docker/ssl-master/out/hub.jonty.top/hub.xxx.key.pem -> ../cert.key.pem lrwxrwxrwx. 1 root root 11 Jul 12 16:06 /root/docker/ssl-master/out/hub.jonty.top/root.crt -> ../root.crt [root@nexus3 ssl-master]# cd out/hub.jonty.top/ [root@nexus3 hub.jonty.top]# ls 20220712-1606 hub.jonty.top.bundle.crt hub.jonty.top.crt hub.jonty.top.key.pem root.crt

阿里云签发

如果有域名,可以购买Aliyun免费ssl证书,一年有效期,可以有效避免自签名证书不适用的问题

申请完成后,下载Nginx证书并上传到服务器

本地域名解析

Windows:C:\Windows\System32\drivers\etc\hosts

Linux:vi /etc/hosts

将以下解析加入,测试是否可以ping

192.168.2.xx hub.jonty.top 192.168.2.xx registry.jonty.top

部署

环境准备

安装Docker-Engine

[root@nexus3 ~]# docker -v Docker version 20.10.17, build 100c701 [root@nexus3 ~]# docker compose version Docker Compose version v2.6.0

创建数据路径并设置权限

mkdir -p $PWD/nexus3/data chmod 777 $PWD/nexus3/data cd $PWD/nexus3

将生成的证书复制$PWD/nexus3/certs目录下(2个域名的证书都需要)

[root@nexus3 hub.jonty.top]# cp hub.jonty.top.crt ~/nexus3/certs/ [root@nexus3 hub.jonty.top]# cp hub.jonty.top.key.pem ~/nexus3/certs/ [root@nexus3 hub.jonty.top]# cd ~/nexus3/certs/ [root@nexus3 certs]# ls hub.jonty.top.crt hub.jonty.top.key.pem

标签:nexus,Sonatype,管理,数据,数据库,SSL,域名 来源:

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。



这篇关于Sonatype Nexus3 搭建私有仓库的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程