_

nginx转发外网推送harbor失败[已解决]

航仔 7天前 ⋅ 30 阅读

当通过nginx代理外网访问Harbor时,遇到push镜像失败,表现为'unauthorized: authentication required'。

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

/opt/harbor/harbor.yml 配置文件 只开启http

hostname: localhost

# http related config
http:
  # port for http, default is 80. If https enabled, this port will redirect to https port
  port: 5000

# https related config
#https:
  # https port for harbor, default is 443
#  port: 5000
  # The path of cert and key files for nginx
#  certificate: /www/server/panel/vhost/ssl/harbor.xuehang.ren/fullchain.pem
#  private_key: /www/server/panel/vhost/ssl/harbor.xuehang.ren/privkey.pem
  # enable strong ssl ciphers (default: false)
  # strong_ssl_ciphers: false

nginx 伪静态配置 (重点修改 proxy_set_header X-Forwarded-Proto https;)

location ^~ / {
  proxy_redirect off;
  proxy_pass http://127.0.0.1:5000/;
  proxy_cookie_path /hang/ /;  ##设置cookie路径,从而不导致每次发生请求发生变化。
  proxy_cookie_path /hang /;
  proxy_set_header Host $host;
  proxy_set_header Referer $http_referer;
  proxy_set_header Cookie $http_cookie;   ##请求发送时携带cookie信息
  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 https;
}

重启barbor

## 关闭docker-compose
docker-compose down -n
## 进入/opt/harbor 刷新配置文件
./prepare
## 重新启动docker-compose
docker-compose up -d

已解决

 


全部评论: 0

    我有话说: