由于环境为内网,dmz区域nginx主机只有80端口对外开放
现需要从外网80访问内网harbor,需要访问页面和推拉镜像,同时需要公网和内网harbor同步
由于反向代理访问harbor会返回registry的ip+端口,然后harbor再去访问这个ip+端口,会因网络不通无法访问
使用虚拟域名harbor.test.work,访问需要在本机配置hosts对应公网IP
10.100.1.3 Harbor
10.100.1.1 DMZ-Nginx
#内网主机的/etc/hosts添加(nginx和harbor和访问端)
10.100.1.3 harbor.test.work
#harbor.yml配置添加
hostname: harbor.test.work
external_url: http://harbor.test.work:80
#DMZ-Nging转发配置
server {
server_name harbor.test.work;
listen 80;
location / {
proxy_pass http://10.100.1.3:80;
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_buffering off;
proxy_request_buffering off;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header X-Forwarded-Proto $scheme;
}
}
#harbor的访问端的docker-compose.yml中core和jobservice添加hosts映射
core:
volumes:
- /etc/hosts:/etc/hosts
jobservice:
volumes:
- /etc/hosts:/etc/hosts
外网harbor添加内网harbor仓库
之后添加复制管理中添加复制任务即可