由于dmz区域nginx主机只有80端口对外开放,内网主机无法访问
现需要从外网80访问内网harbor的5000端口,需要访问页面和推拉镜像,同时实现公网和内网harbor同步
使用虚拟域名harbor.test.work,访问需要在本机配置hosts对应公网IP
#内网主机的/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:5000;
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仓库
之后添加复制管理中添加复制任务即可