自托管 gitlab + 注册表仅显示白色空白页,正确吗?

自托管 gitlab + 注册表仅显示白色空白页,正确吗?

我正在 docker 环境中为我的公司运行一个自托管的 Gitlab,并且我们想要托管我们自己的 docker 镜像,所以我阅读文档但我做不到docker login registry.mycompany-domain.tld,我总是得到unauthorized: HTTP Basic: Access denied ,当我去时,https://registry.mycompany-domain.tld我只得到一张空白页。我不知道这是否正确,但我怀疑有些东西无法正常工作。

由于防火墙原因,我无法启用 gitlab 映像自动获取让我们加密证书(我需要在不同的主机上执行此操作),因此我进行了以下设置:

  • 我有一个docker-compose.yml文件/opt/gitlab并公开这些端口:
    • 127.0.0.1:1443:443
    • '22:22'
  • /etc/nginx/sites-enabled/gitlab我将域配置 gitlab.mycompany.tld为代理https://localhost:1443
  • 主主机上的 nginx 使用 let's encrypt 证书,docker 容器上的 nginx 使用自签名证书。

此设置有效,我可以通过 SSH 和 Web 界面访问 Gitalb,没有任何问题。

我决定为注册表使用单独的域: registry.mycompany-domain.tld然后我在docker-compose.yml文件的 obminus 部分启用注册表。现在看起来像这样(自签名证书位于/etc/CA):

--

# generated using example from https://docs.gitlab.com/omnibus/docker/#install-gitlab-using-docker-compose
# GITLAB_HOME=/opt/gitlab/container

web:
  image: 'gitlab/gitlab-ee:13.11.3-ee.0'
  restart: always
  hostname: gitlab.mycompany.tld
  shm_size: 256m
  environment:
    GITLAB_OMNIBUS_CONFIG: |
        external_url 'https://gitlab.mycompany.tld'
        letsencrypt['enable'] = false
        nginx['ssl_certificate'] = '/certificates/gitlab/gitlab.fullchain.crt'
        nginx['ssl_certificate_key'] = '/certificates/gitlab/gitlab.key'
        nginx['redirect_http_to_https'] = true
        nginx['real_ip_header'] = 'X-Forwarded-For'
        nginx['real_ip_recursive'] = 'on'
        mattermost_nginx['redirect_http_to_https'] = true

        registry_external_url 'https://registry.mycompany.tld'
        registry['enable'] = true
        registry_nginx['redirect_http_to_https'] = true
        registry_nginx['ssl_certificate'] = '/certificates/gitlab/gitlab.fullchain.crt'
        registry_nginx['ssl_certificate_key'] = '/certificates/gitlab/gitlab.key'
        gitlab_rails['registry_enabled'] = true
        gitlab_rails['registry_host'] = "registry.mycompany.tld"

        gitlab_rails['smtp_enable'] = true
        ...

  ports:
    - '127.0.0.1:1443:443'
    - '22:22'
  volumes:
    - '$GITLAB_HOME/config:/etc/gitlab'
    - '$GITLAB_HOME/logs:/var/log/gitlab'
    - '$GITLAB_HOME/data:/var/opt/gitlab'
    - '/etc/CA:/certificates'

我的/etc/nginx/sites-enabled/registry文件如下所示:

server {
    listen 80;
    server_name registry.mycompany.tld;
    access_log  /var/log/nginx/registry.mycompany.tld-access.log;
    error_log   /var/log/nginx/registry.mycompany.tld-error.log;

    location /.well-known {
        root /var/certbot/acme-challenges;
    }   

    location / { 
        return 301 https://$host$request_uri;
    }   

}


# see https://gitlab.com/gitlab-org/gitlab/blob/master/lib/support/nginx/registry-ssl
server {
    listen 443 http2;
    server_name registry.mycompany.tld;
    access_log  /var/log/nginx/ssl_registry.mycompany.tld-access.log;
    error_log   /var/log/nginx/ssl_registry.mycompany.tld-error.log;

    client_max_body_size 0;
    chunked_transfer_encoding on;

    ssl on; 

    ssl_certificate     /etc/letsencrypt/live/registry.mycompany.tld/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/registry.mycompany.tld/privkey.pem;
    ssl_prefer_server_ciphers on;
    ssl_session_cache  builtin:1000  shared:SSL:10m;
    ssl_session_timeout  5m;

    location /{
        proxy_cache off;
        proxy_pass  https://localhost:1443;
        proxy_ssl_certificate         /etc/CA/gitlab/gitlab.fullchain.crt;
        proxy_ssl_certificate_key     /etc/CA/gitlab/gitlab.key;
        proxy_ssl_trusted_certificate /etc/CA/CA.crt;

        proxy_ssl_verify        on;
        proxy_ssl_session_reuse on;
        include /etc/nginx/proxy_params;
        proxy_read_timeout 3600;
    }
}

如果我看一下/opt/gitlab/container/logs/registry/current我就能看到

2021-06-01_16:44:21.01934 time="2021-06-01T16:44:21Z" level=warning msg="error authorizing context: authorization token required" correlation_id=xxxx go_version=go1.15.8 root_repo=
2021-06-01_16:44:21.01966 {"content_type":"application/json","correlation_id":"xxxx","duration_ms":2,"host":"registry.mycompany.tld","level":"info","method":"GET","msg":"access","proto":"HTTP/1.1","referrer":"","remote_addr":"127.0.0.1:56368","remote_ip":"xxxx","status":401,"system":"http","time":"2021-06-01T16:44:21Z","ttfb_ms":2,"uri":"/v2/","user_agent":"Docker-Client/20.10.0-dev (linux)","written_bytes":87}

我真的不明白这意味着什么。 Gitlab docker 容器自动创建了一个文件(/opt/gitlab/container/data/registry/config.yml),所以我真的不知道该怎么做。

我在这里缺少什么?

相关内容