I am running a Gitlab Community Edition Installation with docker-compose.
I try to enable the Container Registry for this Installation.
The GitLab installation is running behind a nginx.
When I try to login to the container registry with the following command:
docker login -v https://my-domain.de -u my_username -p my_password
I see the following error:
Error response from daemon: login attempt to https://my-domain.de/v2/ failed with status: 502 Bad Gateway
In the nginx logs I see this:
[error] 1588#1588: *5561862 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 111.22.33.23, server: my-domain.de, request: "GET /v2/ HTTP/1.1", upstream: "http://111.22.33.23:5050/v2/", host: "my-domain.de"
111.22.33.23 - - [20/Jun/2024:10:12:40 +0000] "GET /v2/ HTTP/1.1" 502 1214 "-" "docker/20.10.17 go/go1.17.11 git-commit/a89b842 kernel/5.15.153.1-microsoft-standard-WSL2 os/linux arch/amd64 UpstreamClient(Docker-Client/20.10.17 x5C(windowsx5C))" "-"
2024/06/20 10:12:40 [error] 1588#1588: *5561864 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 111.22.33.23, server: my-domain.de, request: "GET /v2/ HTTP/1.1", upstream: "http://111.22.33.23:5050/v2/", host: "my-domain.de"
144.41.141.123 - - [20/Jun/2024:10:12:40 +0000] "GET /v2/ HTTP/1.1" 502 1214 "-" "docker/20.10.17 go/go1.17.11 git-commit/a89b842 kernel/5.15.153.1-microsoft-standard-WSL2 os/linux arch/amd64 UpstreamClient(Docker-Client/20.10.17 x5C(windowsx5C))" "-"
This are the relevant parts of my setup:
nginx config
upstream backgitlab {
server 111.22.33.23:30080;
}
upstream gitlab_registry {
server 111.22.33.23:5050;
}
server {
listen 443 ssl;
server_name my-domain.de;
ssl settings
location /gitlab {
proxy_pass http://backgitlab;
include /etc/nginx/proxy.conf;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Protocol $scheme;
proxy_set_header X-Url-Scheme $scheme;
proxy_set_header X-Forwarded-Ssl on;
}
location / {
proxy_pass http://gitlab_registry;
include /etc/nginx/proxy.conf;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Protocol $scheme;
proxy_set_header X-Url-Scheme $scheme;
proxy_set_header X-Forwarded-Ssl on;
}
docker-compose.yml
external_url 'https://my-domain.de/gitlab'
gitlab_rails['gitlab_shell_ssh_port'] = 30022
registry['enable'] = true
registry_external_url = 'https://my-domain.de:5050'
gitlab_rails['registry_enabled'] = true
gitlab_rails['registry_host'] = "my-domain.de"
gitlab_rails['registry_port'] = "5050"
gitlab_rails['registry_path'] = "/var/opt/gitlab/gitlab-rails/shared/registry"
registry['storage'] = {
'filesystem': {
'rootdirectory': '/var/opt/gitlab/gitlab-rails/shared/registry'
}
}
registry_nginx['listen_port'] = 4678
registry_nginx['redirect_http_to_https'] = false
registry_nginx['listen_https'] = false
registry_nginx['enable'] = false
registry_nginx['proxy_set_headers'] = {
"X-Real-IP" => "remote_addr",
"X-Forwarded-Proto" => "https",
"X-Forwarded-Ssl" => "on"
}
ports:
- "30080:80"
- "30022:22"
- "5050:5050"