栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

nginx外网 + harbor拉取推送镜像

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

nginx外网 + harbor拉取推送镜像

文章目录
  • 1,问题描述
  • 2,问题解决

1,问题描述

nginx外网 + harbor nginx容器配置:

外网nginx代理后harbor域名:harbor01.io   
 harbor.cfg ( hostname = 192.168.56.72 ) ---> pull harbor01.io/xx/yy  err
 harbor.cfg ( hostname = harbor01.io )   ---> pull harbor01.io/xx/yy  ok, push err

common/config/nginx/nginx.conf  
 修改配置/ , /v2/ , /service/ 
 (proxy_set_header X-Forwarded-Proto https) ---> push harbor01.io/xx/yy  ok, pull err

能pull镜像,但是push 镜像出现的问题:unauthorized: authentication required

[root@c7 wrapper-linux-x86-64-3.5.49]# docker push harbor01.io/kuai/nginx
The push refers to repository [harbor01.io/kuai/nginx]
d9eb91d66e2a: Pushing [==================================================>]  3.584kB
ae1f545e4c08: Pushing [=============>                                     ]     512B/1.961kB
c20672db3628: Pushing [==================================================>]  3.072kB
4cbb728cd302: Preparing
9eb82f04c782: Preparing
unauthorized: authentication required
2,问题解决

参考:https://www.cnblogs.com/chenminklutz/p/13446164.html

  • 把X-Forwarded-Proto设置为https,临时解决外网push镜像问题
  • 把X-Forwarded-Proto还原,临时解决pull镜像问题
#################### docker客户端pull / push 镜像
[root@c7 ~]# docker push harbor01.io/kuai/nginx
The push refers to repository [harbor01.io/kuai/nginx]
d9eb91d66e2a: Pushing [==================================================>]  3.584kB
ae1f545e4c08: Pushing [=============>                                     ]     512B/1.961kB
c20672db3628: Pushing [==================================================>]  3.072kB
4cbb728cd302: Preparing
9eb82f04c782: Preparing
unauthorized: authentication required

#################### harbor服务端
#1,修改harbor.cfg  ,把hostname改为与外网nginx一致的代理域名
[root@JXQ-11-243-32-211 harbor]# grep hostname /export/harbor/harbor.cfg 
#hostname = 192.168.56.72
hostname = harbor01.io

#2,修改harbor nginx容器配置
[root@JXQ-11-243-32-211 harbor]# cd common/config/nginx/
[root@JXQ-11-243-32-211 nginx]# ll
total 32
drwx------ 2 65534 root 4096 Apr 18 15:57 client_body_temp
drwxr-xr-x 2 root  root 4096 Apr 18 15:57 conf.d
drwx------ 2 65534 root 4096 Apr 18 15:57 fastcgi_temp
-rw-r----- 1 root  root 3353 Apr 25 09:35 nginx.conf
-rw-r----- 1 root  root 3654 Apr 22 15:21 nginx.conf.bak
drwx------ 2 65534 root 4096 Apr 18 15:57 proxy_temp
drwx------ 2 65534 root 4096 Apr 18 15:57 scgi_temp
drwx------ 2 65534 root 4096 Apr 18 15:57 uwsgi_temp

# 备份原有的配置文件 .ori , 然后修改nginx.conf
[root@JXQ-11-243-32-211 harbor]# cp common/config/nginx/nginx.conf common/config/nginx/nginx.conf.ori 
[root@JXQ-11-243-32-211 harbor]# cp common/config/nginx/nginx.conf common/config/nginx/nginx.conf.https 
[root@JXQ-11-243-32-211 harbor]# vim common/config/nginx/nginx.conf.https
# 修改配置/ , /v2/ , /service/ 
#	  (proxy_set_header X-Forwarded-Proto https) ---> pull harbor01.io/xx/yy  err, push ok	  
[root@JXQ-11-243-32-211 harbor]# grep 'X-Forwarded-Proto' common/config/nginx/nginx.conf.https 
      proxy_set_header X-Forwarded-Proto https;
      proxy_set_header X-Forwarded-Proto $scheme;
      proxy_set_header X-Forwarded-Proto $scheme;
      proxy_set_header X-Forwarded-Proto $scheme;
      proxy_set_header X-Forwarded-Proto https;
      proxy_set_header X-Forwarded-Proto https;

[root@JXQ-11-243-32-211 harbor]# cd common/config/nginx/
[root@JXQ-11-243-32-211 nginx]# ln -sf nginx.conf.https  nginx.conf
[root@JXQ-11-243-32-211 nginx]# ll
total 32
drwx------ 2 65534 root 4096 Apr 18 15:57 client_body_temp
drwxr-xr-x 2 root  root 4096 Apr 18 15:57 conf.d
drwx------ 2 65534 root 4096 Apr 18 15:57 fastcgi_temp
lrwxrwxrwx 1 root  root   14 Apr 25 10:14 nginx.conf -> nginx.conf.https
-rw-r----- 1 root  root 3647 Apr 25 10:14 nginx.conf.https
-rw-r----- 1 root  root 3653 Apr 25 09:40 nginx.conf.ori
	  
[root@JXQ-11-243-32-211 nginx]# docker restart nginx
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/836026.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号