Hello, I have a problem with my GitLab install. This morning I enabled registry on a separate domain because I can’t use ports with Cloudflare (and also because I find that more “beautiful”… ). But now, I can’t connect on my registry with the
docker login registry.gitlab.domain.tld
command. I have this error message:
Error response from daemon: Get "https://registry.gitlab.domain.tld/v2/": denied: access forbidden
I configured my instance behind a reverse proxy with Apache2. Here is my virtualhost config file
<VirtualHost *:80>
ServerName gitlab.domain.tld
ServerSignature Off
RewriteEngine on
RewriteCond %{HTTPS} !=on
RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [NE,R,L]
</VirtualHost>
<VirtualHost *:443>
SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/gitlab.domain.tld/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/gitlab.domain.tld/privkey.pem
SSLCertificateChainFile /etc/letsencrypt/live/gitlab.domain.tld/chain.pem
SSLProtocol all -SSLv2 -SSLv3
SSLHonorCipherOrder on
SSLCompression off
SSLOptions +StrictRequire
SSLCipherSuite ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:CAMELLIA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA
Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains"
ServerName gitlab.domain.tld
ServerSignature Off
ProxyPreserveHost On
# Ensure that encoded slashes are not decoded but left in their encoded state.
# http://doc.gitlab.com/ce/api/projects.html#get-single-project
AllowEncodedSlashes NoDecode
<Location />
# New authorization commands for apache 2.4 and up
# http://httpd.apache.org/docs/2.4/upgrading.html#access
Require all granted
#Allow forwarding to gitlab-workhorse
ProxyPassReverse http://127.0.0.1:8180
ProxyPassReverse http://gitlab.domain.tld
</Location>
# Apache equivalent of nginx try files
# http://serverfault.com/questions/290784/what-is-apaches-equivalent-of-nginxs-try-files
# http://stackoverflow.com/questions/10954516/apache2-proxypass-for-rails-app-gitlab
RewriteEngine on
########
## LIS SOFIANE!
##
## Il faut regarder /etc/gitlab/gitlab.rb pour voir les ports utilisés
## Check aussi ce post si jamais les images disparaissent à nouveau: https://forum.gitlab.com/t/uploaded-images-dont-shows-up-with-custom-width/64621/3?u=sofianelasri
########
# Don't escape encoded characters in API requests. This makes the IDE work.
# Don't escape encoded characters in -/refs/*/logs_tree/ or -/tree/, since 12.85,
# these are pre-encoded, and excluding them causes double-encoding.
RewriteCond %{REQUEST_URI} ^/api/v\d+/.* [OR]
RewriteCond %{REQUEST_URI} .*-/branches/.* [OR]
RewriteCond %{REQUEST_URI} .*-/refs/.*/logs_tree/.* [OR]
RewriteCond %{REQUEST_URI} .*-/tree/.*
RewriteRule .* http://127.0.0.1:8182%{REQUEST_URI} [P,QSA,NE]
# Forward all requests to gitlab-workhorse except existing files like error documents
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f [OR]
RewriteCond %{REQUEST_URI} ^/uploads/.*
RewriteRule .* http://127.0.0.1:8182%{REQUEST_URI} [P,QSA]
RequestHeader set X_FORWARDED_PROTO 'https'
RequestHeader set X-Forwarded-Ssl on
# needed for downloading attachments
DocumentRoot /opt/gitlab/embedded/service/gitlab-rails/public
#Set up apache error documents, if back end goes down (i.e. 503 error) then a maintenance/deploy page is thrown up.
ErrorDocument 404 /404.html
ErrorDocument 422 /422.html
ErrorDocument 500 /500.html
ErrorDocument 502 /502.html
ErrorDocument 503 /503.html
# It is assumed that the log directory is in /var/log/httpd.
# For Debian distributions you might want to change this to
# /var/log/apache2.
LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b" common_forwarded
ErrorLog ${APACHE_LOG_DIR}/gitlab.domain.tld_error.log
CustomLog ${APACHE_LOG_DIR}/gitlab.domain.tld_forwarded.log common_forwarded
CustomLog ${APACHE_LOG_DIR}/gitlab.domain.tld_access.log combined env=!dontlog
CustomLog ${APACHE_LOG_DIR}/gitlab.domain.tld.log combined
</VirtualHost>
<VirtualHost *:80>
ServerName registry.gitlab.domain.tld
ServerSignature Off
RewriteEngine on
RewriteCond %{HTTPS} !=on
RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [NE,R,L]
</VirtualHost>
<VirtualHost *:443>
SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/registry.gitlab.domain.tld/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/registry.gitlab.domain.tld/privkey.pem
SSLCertificateChainFile /etc/letsencrypt/live/registry.gitlab.domain.tld/chain.pem
SSLProtocol all -SSLv2 -SSLv3
SSLHonorCipherOrder on
SSLCompression off
SSLOptions +StrictRequire
SSLCipherSuite ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:CAMELLIA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA
Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains"
ServerName registry.gitlab.domain.tld
ServerSignature Off
ProxyPreserveHost On
# Ensure that encoded slashes are not decoded but left in their encoded state.
# http://doc.gitlab.com/ce/api/projects.html#get-single-project
AllowEncodedSlashes NoDecode
<Location />
Require all granted
ProxyPass http://127.0.0.1:5000/ timeout=900
ProxyPassReverse http://127.0.0.1:5000/
</Location>
Header always set Docker-Distribution-Api-Version "registry/2.0"
RequestHeader set X-Forwarded-Proto "https"
# It is assumed that the log directory is in /var/log/httpd.
# For Debian distributions you might want to change this to
# /var/log/apache2.
LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b" common_forwarded
ErrorLog ${APACHE_LOG_DIR}/registry.gitlab.domain.tld_error.log
CustomLog ${APACHE_LOG_DIR}/registry.gitlab.domain.tld_forwarded.log common_forwarded
CustomLog ${APACHE_LOG_DIR}/registry.gitlab.domain.tld_access.log combined env=!dontlog
CustomLog ${APACHE_LOG_DIR}/registry.gitlab.domain.tld.log combined
</VirtualHost>
I can access to the registry domain without difficulties, it shows me some json code that ask me to authenticate. So I don’t think it’s a problem from my virtualhost configuration. I found some topics that discuss about this problem, here are two of them:
But none of the ones I found helped me. I checked the yaml config file located in /var/opt/gitlab/registry
, and I use the right auth.token.realm
url with https protocol.
Here is my registry configuration in the gitlab.rb config file:
################################################################################
## Container Registry settings
##! Docs: https://docs.gitlab.com/ee/administration/container_registry.html
################################################################################
registry_external_url 'https://registry.gitlab.domain.tld'
### Settings used by GitLab application
gitlab_rails['registry_enabled'] = true
gitlab_rails['registry_host'] = "registry.gitlab.domain.tld"
# gitlab_rails['registry_port'] = "5005"
# gitlab_rails['registry_path'] = "/var/opt/gitlab/gitlab-rails/shared/registry"
I have no idea how to fix that.
I am using GitLab CE v16.1.2.
Thanks in advance for help !