Harbor 1.2.2 无法获得镜像列表

Harbor 1.2.2 无法获得镜像列表

现象

老旧的harbor 1.2.2界面看不到镜像了.harbor镜像在界面上总是处于loading状态,因长期CI/CD流水线生产了很多镜像,导致前台页面无返回.后台通过curlAPI获取查询镜像的tag,命令如下:

curl -u "用户:密码" -X GET  -H "Content-Type: application/json"   "https://harbor.xxx.com/api/repositories/app%2Fapp01/"

返回Nginx:504 Gateway Time-out

原来是nginx 代理超时了,看来镜像是有点多.

解决

docker 登陆harbor后台nginx

增加参数 proxy_read_timeout 6000 ;
如果前面过了7层也要一起修改.

worker_processes auto;

events {
  worker_connections 1024;
  use epoll;
  multi_accept on;
}

http {
  tcp_nodelay on;
  include /etc/nginx/conf.d/*.upstream.conf;

  # this is necessary for us to be able to disable request buffering in all cases
  proxy_http_version 1.1;

  upstream registry {
    server registry:5000;
  }

  upstream ui {
    server ui:80;
  }
  
  log_format timed_combined '$remote_addr - '
    '"$request" $status $body_bytes_sent '
    '"$http_referer" "$http_user_agent" '
    '$request_time $upstream_response_time $pipe';

  access_log /dev/stdout timed_combined;

  include /etc/nginx/conf.d/*.server.conf;

  server {
    listen 443 ssl;
#    server_name harbordomain.com;

    # SSL
    ssl_certificate /etc/nginx/cert/staff.xdf.cn.pem;
    ssl_certificate_key /etc/nginx/cert/staff.xdf.cn.key;
  
    # Recommendations from https://raymii.org/s/tutorials/Strong_SSL_Security_On_nginx.html
    ssl_protocols TLSv1.1 TLSv1.2;
    ssl_ciphers '!aNULL:kECDH+AESGCM:ECDH+AESGCM:RSA+AESGCM:kECDH+AES:ECDH+AES:RSA+AES:';
    ssl_prefer_server_ciphers on;
    ssl_session_cache shared:SSL:10m;
  
    # disable any limits to avoid HTTP 413 for large image uploads
    client_max_body_size 0;
  
    # required to avoid HTTP 411: see Issue #1486 (https://github.com/docker/docker/issues/1486)
    chunked_transfer_encoding on;

    location / {
      proxy_pass http://ui/;
      proxy_set_header Host $http_host;
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      
      # When setting up Harbor behind other proxy, such as an Nginx instance, remove the below line if the proxy already has similar settings.
      proxy_set_header X-Forwarded-Proto $scheme;

      # Add Secure flag when serving HTTPS
      proxy_cookie_path / "/; secure";

      proxy_buffering off;
      proxy_request_buffering off;
      proxy_read_timeout 6000; 
    }

    location /v1/ {
      return 404;
    }

    location /v2/ {
      proxy_pass http://ui/registryproxy/v2/;
      proxy_set_header Host $http_host;
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      
      # When setting up Harbor behind other proxy, such as an Nginx instance, remove the below line if the proxy already has similar settings.
      proxy_set_header X-Forwarded-Proto $scheme;
      proxy_buffering off;
      proxy_request_buffering off;
      proxy_read_timeout 6000; 
    }

    location /service/ {
      proxy_pass http://ui/service/;
      proxy_set_header Host $http_host;
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      
      # When setting up Harbor behind other proxy, such as an Nginx instance, remove the below line if the proxy already has similar settings.
      proxy_set_header X-Forwarded-Proto $scheme;

      proxy_buffering off;
      proxy_request_buffering off;
      proxy_read_timeout 6000; 
    }

        location /service/notifications {
      return 404;
    }
  }
    server {
      listen 80;
      #server_name harbordomain.com;
      return 301 https://$host$request_uri;
  } 
}

重启nginx 容器后解决.

下面就是研究harbor的镜像清理了.