[转] 使用HTTPS在Nexus Repository Manager 3.0上搭建私有Docker仓库
FROM: https://www.hifreud.com/2018/06/06/03-nexus-docker-repository-with-ssl/
搭建方式
搭建SSL的Nexus官方提供两种方式
- 第一种是反向代理服务器,Nexus Repository Manager使用HTTP对外提供服务,然后使用Nginx之类的反向代理服务器对外提供HTTPS服务,但是反向代理服务器与Nexus Repository Manager之间依旧使用HTTP交互。
- 第二种就是比较正常的,在Nexus Repository Manager上做一些配置,使得Nexus Repository Manager直接对外提供HTTPS服务。
本文主要描述的就是第二种方式
配置HTTPS
生成keystore文件
在项目的$install-dir/etc/ssl/目录下,执行命令
#{NEXUS_DOMAIN} = nexus为服务器域名
#{NEXUS_IP} = 192.168.59.1 为服务器IP
$ cd $install-dir/etc/ssl/
$ keytool -genkeypair -keystore keystore.jks -storepass nexus3 -keypass nexus3 -alias jetty -keyalg RSA -keysize 2048 -validity 5000 -dname "CN=*.{NEXUS_DOMAIN}, OU=Example, O=Sonatype, L=Unspecified, ST=Unspecified, C=US" -ext "SAN=DNS:{NEXUS_DOMAIN},IP:{NEXUS_IP}" -ext "BC=ca:true"
添加SSL端口
修改$data-dir/etc/nexus.properties文件,在第一行添加application-port-ssl=8443
添加HTTPS支持配置文件
修改$data-dir/etc/nexus.properties文件,修改Key为nexus-args所在行的值,在后面添加,${jetty.etc}/jetty-https.xml,${jetty.etc}/jetty-http-redirect-to-https.xml
nexus-args=${jetty.etc}/jetty.xml,${jetty.etc}/jetty-http.xml,${jetty.etc}/jetty-requestlog.xml,${jetty.etc}/jetty-https.xml,${jetty.etc}/jetty-http-redirect-to-https.xml
修改HTTPS配置文件
修改${jetty.etc}/jetty-https.xml文件中keystore和truststore的配置部分
<Set name="KeyStorePath"><Property name="ssl.etc"/>/keystore.jks</Set>
<Set name="KeyStorePassword">nexus3</Set>
<Set name="KeyManagerPassword">nexus3</Set>
<Set name="TrustStorePath"><Property name="ssl.etc"/>/keystore.jks</Set>
<Set name="TrustStorePassword">nexus3</Set>
验证
重新启动服务
$nexus.exe /run
Web访问
可以访问http://localhost:8081/或者https://localhost:8443/来查看,如果能够正常打开网页则配置成功。此处由于配置了jetty-http-redirect-to-https.xml,所以在访问http的时候会自动redirect到https地址。
docker配置
登录报错
[root@localhost docker]# docker login -u admin -p admin123 192.168.59.1:8551
Error response from daemon: Get https://192.168.59.1:8551/v1/users/: x509: certificate signed by unknown authority
此处有个小插曲就是之前是报错如下
Error response from daemon: Get https://192.168.59.1:8551/v1/users/: x509: cannot validate certificate for 192.168.59.1 because it doesn't contain any IP SANs这是因为在生成keystore的时候没有指定IP
此处有两种方式解决上述问题,第一种是添加insecure-registries,不对SSL进行认证校验,第二种是安装签名证书,进行校验。
1-修改daemon.json文件
[root@localhost docker]# vi /etc/docker/daemon.json
{
"insecure-registries": [
"192.168.59.1:8551"
],
"disable-legacy-registry": true
}
[root@localhost docker]# service docker restart
[root@localhost docker]# docker login -u admin -p admin123 192.168.59.1:8551
Login Succeeded
2-配置ca-trust(centos)
[root@localhost docker]# docker login -u admin -p admin123 192.168.59.1:8551
Error response from daemon: Get https://192.168.59.1:8551/v2/: x509: certificate has expired or is not yet valid
出现上述问题,搜索之后大多数人说是服务器时间不同步问题,解决如下:
# 先解决时区问题
[root@localhost ~]# ls -l /etc/localtime
lrwxrwxrwx. 1 root root 38 Apr 25 07:09 /etc/localtime -> ../usr/share/zoneinfo/America/New_York
[root@localhost ~]# rm -f /etc/localtime
[root@localhost ~]# ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
# 在解决时间问题
[root@localhost docker]# yum install ntp.x86_64
# 可用的ntp服务器列表 http://www.ntp.org.cn/pool.php
[root@localhost docker]# ntpdate cn.ntp.org.cn
6 Jun 17:50:20 ntpdate[18252]: no server suitable for synchronization found
# 由于公司代理服务器问题,连接不上NTP服务器,所以手动设置
[root@localhost ~]# date -s 20180606
Wed Jun 6 00:00:00 CST 2018
[root@localhost ~]# date -s 17:53:35
Wed Jun 6 17:53:35 CST 2018
基于centos7.0版本,生成和导入cert文件
#生成cert文件
[root@localhost ~]# keytool -printcert -sslserver 192.168.59.1:8443 -rfc >nexus.crt
[root@localhost ~]# yum install ca-certificates
[root@localhost ~]# update-ca-trust force-enable
# 还可以放在/etc/docker/certs.d/192.168.59.1:8443目录下
[root@localhost ~]# mv nexus.crt /etc/pki/ca-trust/source/anchors/nexus.crt
[root@localhost ~]# update-ca-trust
[root@localhost ~]# service docker restart
[root@localhost ~]# docker login -u admin -p admin123 192.168.59.1:8551
Error response from daemon: Get https://192.168.59.1:8551/v2/: x509: certificate signed by unknown authority
Pekkle: 亲测,在centos 7.2中,把证书文件放入 /etc/pki/ca-trust/source/anchors ,然后执行 update-ca-trust , 再重启docker服务,之后docker成功链接nexus https。
对于Ubuntu系统来说certificate的存放路径是/usr/local/share/ca-certificates
#生成cert文件
[root@localhost ~]# keytool -printcert -sslserver 192.168.59.1:8443 -rfc >nexus.crt
# 还可以放在/etc/docker/certs.d/192.168.59.1:8443目录下
[root@localhost ~]# mv nexus.crt /usr/local/share/ca-certificates/nexus.crt
[root@localhost ~]# update-ca-certificates
[root@localhost ~]# service docker restart
[root@localhost ~]# docker login -u admin -p admin123 192.168.59.1:8551
依然报错如上,说是Unkonw authority,搜索之后发现 一般情况下,证书只支持域名访问,要使其支持IP地址访问,需要修改配置文件openssl.cnf。
在Redhat7系统中,文件所在位置是/etc/pki/tls/openssl.cnf。在其中的[ v3_ca]部分,添加subjectAltName选项:
[ v3_ca ]
subjectAltName = IP:192.168.59.1
再次执行docker login
[root@localhost ~]# service docker restart
[root@localhost ~]# docker login -u admin -p admin123 192.168.59.1:8551
Login Succeeded
至此,大功告成!
參考資料
SSL and Repository Connector Configuration : https://help.sonatype.com/repomanager3/private-registry-for-docker/ssl-and-repository-connector-configuration
Inbound SSL - Configuring to Serve Content via HTTPS : https://help.sonatype.com/repomanager3/security/configuring-ssl#ConfiguringSSL-InboundSSL-ConfiguringtoServeContentviaHTTPS
Using Self-Signed Certificates with Nexus Repository Manager and Docker Daemon https://support.sonatype.com/hc/en-us/articles/217542177-Using-Self-Signed-Certificates-with-Nexus-Repository-Manager-and-Docker-Daemon
ca证书校验用户证书 : https://www.cnblogs.com/cmsd/p/6078705.html
03搭建docker私有仓库 : https://blog.csdn.net/gqtcgq/article/details/51163558
docker 报错:x509 : certificate has expired or is not yet valid: https://blog.csdn.net/bjbs_270/article/details/48784807
linux设置系统时间 : https://www.cnblogs.com/boshen-hzb/p/6269378.html
[转] 使用HTTPS在Nexus Repository Manager 3.0上搭建私有Docker仓库的更多相关文章
- 使用 Nexus Repository Manager 搭建私有docker仓库
使用容器安装Nexus3 1.下载nexus3的镜像: docker pull sonatype/nexus3 2.使用镜像启动一个容器: docker run -d --name nexus -- ...
- docker+Nexus Repository Manager 搭建私有docker仓库
使用容器安装Nexus3 1.下载nexus3的镜像: docker pull sonatype/nexus3 2.使用镜像启动一个容器: docker run -d -p 8081:8081 -p ...
- Nexus Repository Manager 3.0 发布
著名仓库管理工具Nexus,在2016年4月6日发布3.0版本(包括OSS版),相较2.*版本有很大的改变: 1. 从底层重构,从而提高性能,增强扩展能力,并改善用户体验 2. 升级界面,增加更多的浏 ...
- 使用 Nexus Repository Manager 搭建 npm 私服
目录 环境 下载与安装 添加npm仓库 配置与验证npm仓库 发布自己的包 Nexus开启启动 脚注 环境 windows10(1803) Nexus Repository Manager OSS 3 ...
- Nexus Repository Manager 3(CVE-2019-7238) 远程代码执行漏洞分析和复现
0x00 漏洞背景 Nexus Repository Manager 3是一款软件仓库,可以用来存储和分发Maven,NuGET等软件源仓库.其3.14.0及之前版本中,存在一处基于OrientDB自 ...
- Maven私服搭建(Nexus Repository Manager 3)
下载和安装 下载地址:https://help.sonatype.com/repomanager3/download 注意:Nexus Repository Manager 3是一个Java服务器应用 ...
- Nexus Repository Manager OSS 3.x 安装配置
前言想要使用maven搭建项目,但是国内的网络环境可以想象,还有公司自己开发的jar包等问题,所以需要搭建一个maven的私服,这样便于管理. 找了一些教程,顺便记下来,当做笔记. 本文以Window ...
- 威胁快报|Nexus Repository Manager 3新漏洞已被用于挖矿木马传播,建议用户尽快修复
背景 近日,阿里云安全监测到watchbog挖矿木马使用新曝光的Nexus Repository Manager 3远程代码执行漏洞(CVE-2019-7238)进行攻击并挖矿的事件. 值得注意的是, ...
- Nexus Repository Manager 3(CVE-2019-7238) 远程代码执行漏洞复现
0x00 漏洞背景 Nexus Repository Manager 3是一款软件仓库,可以用来存储和分发Maven,NuGET等软件源仓库.其3.14.0及之前版本中,存在一处基于OrientDB自 ...
随机推荐
- struts2下velocity做视图如何访问request,session等内置对象,如:原来webwork的$req
struts2下velocity做视图如何访问request,session等内置对象(转) velocity 内置对象 struts2 requestStruts2环境下用velocity做视图时访 ...
- 转载VC6.0 子窗口和父窗口
这个是我周一在一家公司做的上机题中的一道,当场没做出来.我当时只跟考官说了设计思路,是带回来查了几本资料书之后才完成的.因为有半个学期没用VC开发了……,最近一直都在实践ASP.NET相关的…… 建立 ...
- handsontable-integrations
jquery:可以通过$选择元素 bootstrap:使用bootstrap,有些样式需要重置 backbone:整合
- EBS通过SQL查找所有的定时请求
--查找所有定时请求. --也可以登录系统,在系统管理员下查找特定请求,状态设置为Scheduled进行查询SELECT DISTINCT USER_CONCURRENT_PROGRAM_NAME,B ...
- 基于S2SH开发病房管理系统的设计与实现 源码
基于S2SH开发病房管理系统的设计与实现: 开发环境: Windows操作系统 开发工具:Eclipse/MyEclipse+Jdk+Tomcat+MySQL数据库 运行效果图: 此源码经 ...
- 自定义Team Foundation Server (TFS) 与Project Professional的集成字段
用户可以象使用Office Excel一样,使用Project Professional连接TFS,将数据下载到本地修改,并且发布到TFS服务器上,如果你习惯使用Project来计划你的项目,那么Pr ...
- 强制TFS用户与计算机(域)用户同步
默认情况下,添加到域AD组中的账户不会立刻同步到TFS中. TFS每小时与域控制器同步一次,将计算机安全组中的账户添加到TFS中. 但是可以通过下面几种方式强制TFS立刻同步域中的账户: 1. 在TF ...
- #测试框架推荐# test4j,数据库测试
# 背景 后端都是操作DB的,这块的自动化测试校验的话,是需要数据库操作的,当然可以直接封装方法来操作数据,那么有没有开源框架支持数据操作,让我们关注写sql语句?或者帮我们做mysql的断言呢? # ...
- c#设计模式之策略者模式(Strategy Pattern)
场景出发 假设存在如下游戏场景: 1:角色可以装备木剑,铁剑,魔剑3种装备,分别对怪物造成20HP,50HP,100HP伤害(未佩戴装备则无法攻击); 2角色可以向怪物攻击,一次攻击后损失角色所佩戴装 ...
- ASP.NET 页面执行顺序详解
今天整理了一下ASP执行过程,从.net页码的执行周期开始做一个详细的了解.我重写了页面的绝大多数方法.然后加载执行.所得的顺序如下. 方法是每个重写的事件中都输出一个字符,按字符打印出来的先后判断事 ...