下载harbor安装包:
这边下载的是2.4.1版本
https://github.com/goharbor/harbor/releases/download/v2.4.1/harbor-offline-installer-v2.4.1.tgz
解压harbor离线版安装包
tar xf harbor-offline-installer-v2.4.1.tgz
mv harbor /var/docker
修改harbor安装的配置文件
cd /var/docker/harbor
mv harbor.yml.tmpl harbor.yml
mkdir -p /apps/harbor/data //用于存放harbor的持久化数据
harbor.yml配置文件主要修改参数如下:
hostname: testing.com ///设置访问地址,可以使用ip、域名,不可以设置为127.0.0.1或localhost
http:
# port for http, default is 80. If https enabled, this port will redirect to https port
port: 8080 //设置端口
# https related config //配置(如不需要可不配置,注释掉)
#https:
# https port for harbor, default is 443
# port: 443
# The path of cert and key files for nginx
# certificate: /your/certificate/path
# private_key: /your/private/key/path
harbor_admin_password: Harbor12345 //admin密码,可修改为其他密码
# The default data volume
data_volume: /apps/harbor/data //配置harbor持久化数据存放路径
安装并启动Harbor
./install.sh
安装完成后,平台docker容器正常运行
调整nginx配置
用域名登陆失败,docker login testing.com 失败,查阅资料,修改nginx配置文件得以解决
docker exec -it nginx bash
cd /etc/nginx
vi nginx.conf
#nginx.conf配置文件
# location / ;location /v2/ ;location /service/ 三个都添加 proxy_set_header X-Forwarded-Proto https;
#location /添加 proxy_set_header X-Forwarded-Proto https;
location / {
proxy_pass http://portal/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
#proxy_set_header X-Forwarded-Proto $x_forwarded_proto;
proxy_set_header X-Forwarded-Proto https;
proxy_buffering off;
proxy_request_buffering off;
}
#location /v2/添加 proxy_set_header X-Forwarded-Proto https;
location /v2/ {
proxy_pass http://core/v2/;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
#proxy_set_header X-Forwarded-Proto $x_forwarded_proto;
proxy_set_header X-Forwarded-Proto https;
proxy_buffering off;
proxy_request_buffering off;
proxy_send_timeout 900;
proxy_read_timeout 900;
}
#location /service/添加 proxy_set_header X-Forwarded-Proto https;
location /service/ {
proxy_pass http://core/service/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
#proxy_set_header X-Forwarded-Proto $x_forwarded_proto;
#proxy_set_header X-Forwarded-Proto $x_forwarded_proto;
proxy_set_header X-Forwarded-Proto https;
proxy_buffering off;
proxy_request_buffering off;
}
访问Harbor
http://testing.com admin Harbor12345