goharbor / harbor

An open source trusted cloud native registry project that stores, signs, and scans content.
https://goharbor.io
Apache License 2.0
24k stars 4.75k forks source link

HTTPS nginx proxy HTTP Harbor fail #21080

Open huangjun0210 opened 2 days ago

huangjun0210 commented 2 days ago

nginx and harbor are not on the same node, using nginx proxy harbor service:

but, the proxy fail.

Versions:

Additional context:

Visit Harbor on https://ccimage.***.com

We can successfully login through the portal: image

But use docker login command on node cannot login successfully: image

harbor.yml

hostname: 10.129.227.76

# http related config
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: /root/harbor/ssl/ccimage.***.com.pem
  #  private_key: /root/harbor/ssl/ccimage.***.com.key
  # enable strong ssl ciphers (default: false)
  # strong_ssl_ciphers: false

# # Uncomment following will enable tls communication between all harbor components
# internal_tls:
#   # set enabled to true means internal tls is enabled
#   enabled: true
#   # put your cert and key files on dir
#   dir: /etc/harbor/tls/internal

# ...
# ....

nginx.conf

server {
    listen 443 ssl;
    server_name ccimage.***.com;
   client_max_body_size 0;  

    ssl_certificate /etc/nginx/ssl/ccimage.***.com.pem;
    ssl_certificate_key /etc/nginx/ssl/ccimage.***.com.key;

    location / {
        proxy_pass http://10.129.227.76:8080; 
        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 $scheme;

    }

  location /v2/ {
      proxy_pass http://10.129.227.76:8080/v2/;
      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 $scheme;
  }
}

Log files: image

docooler commented 2 days ago

from the docker login response . we can see your registry auth uri is not right. it's directly return the ip address .not the domain address. please check your config file