Harbor内网离线安装使用HTTPS访问

重要提醒:使用的是域名形式访问Harbor。通过https://harbor.top访问网址

1、首先在自己windows电脑

"此磁盘C->Windows->System32->drivers->etc"

修改hosts文件 添加"ip harbor.top"例如:"172.33.33.33 harbor.top"

2、进入内网服务器 172.33.33.33

修改

shell 复制代码
vi  /etc/hosts 
172.33.33.33 harbor.top

1、生成证书

harbor文件在/root/harbor/

然后再次文件夹下创建mkdir cert文件夹

shell 复制代码
cd cert
openssl genrsa -out ca.key 4096

openssl req -x509 -new -nodes -sha512 -days 3650  -subj "/C=CN/ST=Shanghai/O=dev/OU=IT/CN=harbor.top"  -key ca.key  -out ca.crt

openssl genrsa -out harbor.key 4096

openssl req  -new -sha512  -subj "/C=CN/ST=Shanghai/O=dev/OU=IT/CN=harbor.top"  -key harbor.key  -out harbor.csr 
cat > v3.ext <<-EOF
authorityKeyIdentifier=keyid,issuer
basicConstraints=CA:FALSE
keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment
extendedKeyUsage = serverAuth 
subjectAltName = @alt_names
[alt_names]
DNS.1=harbor.top
EOF
openssl x509 -req -sha512 -days 3650 -extfile v3.ext -CA ca.crt -CAkey ca.key -CAcreateserial -in harbor.csr -out harbor.crt

会生成 ca.crt ca.key ca.srl harbor.crt harbor.csr harbor.key v3.ext

接下来将客户端的证书复制到docker文件夹下

shell 复制代码
mkdir -p /etc/docker/certs.d/harbor.top/

scp harbor.crt 172.33.33.33:/etc/docker/certs.d/harbor.top/

2、配置安装HTTPS证书

shell 复制代码
cd /root/harbor/
vi harbor.yml

修改harbor.yml文件

json 复制代码
hostname: harbor.top
https:
 port: 443
 certificate: /root/harbor/harbor.crt
 private_key: /root/harbor/harbor.key

进入harbor文件,重新编译启动harbor

shell 复制代码
cd /root/harbor/

./prepare

./install.sh

3、docker

修改docker.service

shell 复制代码
vim /lib/systemd/system/docker.service

修改ExecStart 内容

shell 复制代码
ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock --insecure-registry 

4、登录

shell 复制代码
172.33.33.33
docker login harbor.top
Username: admin
 Password: 
 WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
 Configure a credential helper to remove this warning. See
 https://docs.docker.com/engine/reference/commandline/login/#credentials-store
 ​
 Login Succeeded

4、常见问题

1、在https双向验证时出现错误:

shell 复制代码
x509: cannot validate certificate for 172.33.33.33 because it doesn't contain any IP SANs

这个问题是:

(1)harbor.yml里面配置的hostname 是IP地址。

(2)登录的时候使用的是 docker login 172.33.33.33方式登录

网上参考的解决方式:

https://blog.csdn.net/qq_35078688/article/details/124945817

该方式不好解决。建议按照文章。按照文章方式。

相关推荐
qq_409022953 小时前
计算机网络
网络协议·tcp/ip·信息与通信
tan180°3 小时前
Linux网络HTTP(中)(8)
linux·网络·http
锐策4 小时前
深入 RFC 793:TCP 报文头部、MSS 协商与三次握手 / 四次挥手全解析
网络·网络协议·tcp/ip
Strawberry_rabbit5 小时前
程序员工作必需之公网和私网
前端·网络协议
噔噔君6 小时前
嵌入式模组拨号获取IP地址时,设置的ippass是什么原理,起到什么作用?
服务器·网络协议·tcp/ip·ip
SRC_BLUE_177 小时前
NSSCTF - Web | 【SWPUCTF 2021 新生赛】Do_you_know_http
网络·网络协议·http
ehiway7 小时前
国际先进!中科亿海微国产嵌入式FPGA IP核及EDA系统设计技术通过科技成果评价
网络协议·tcp/ip·fpga开发
“αβ”8 小时前
了解“网络协议”
linux·服务器·网络·c++·网络协议·tcp/ip·tcp
小吴-斌12 小时前
本地请求接口报SSL错误解决办法(Could not verify * SSL certificate)
网络·网络协议·ssl
草莓熊Lotso12 小时前
基于容器适配器模式的 Stack 与 Queue 实现:复用底层容器的优雅设计
c++·网络协议·rpc·适配器模式