GitLab Registry non-https request redirects to GitLab Domain
Summary
When setting up GitLab Registry, if we set the domain to https
and try to access the GitLab Registry domain without https
, then it redirects to GitLab domain, not GitLab Registry domain with https.
So, if my registry domain is say, registry.wpquark.io
and if I try to access, http://registry.wpquark.io
, then it
redirects to https://wpquark.io
and NOT https://registry.wpquark.io
.
This prevents from automatic SSL certificate renewal through certbot/let's encrypt.
Steps to reproduce
I have a instance of GitLab CE running on my server. The domain config is like this.
- GitLab Instance: https://wpquark.io
- GitLab Registry: https://registry.wpquark.io
In the /etc/gitlab/gitlab.rb
the relevant settings are:
# GitLab
#
external_url "https://wpquark.io"
nginx['redirect_http_to_https'] = true
nginx['listen_addresses'] = ['139.162.39.232', '192.168.136.224', '[2400:8901::f03c:91ff:fe73:e628]']
nginx['ssl_certificate'] = "/etc/letsencrypt/live/wpquark.io/fullchain.pem"
nginx['ssl_certificate_key'] = "/etc/letsencrypt/live/wpquark.io/privkey.pem"
nginx['custom_gitlab_server_config'] = "location ^~ /.well-known { root /var/www/letsencrypt; }"
# Registry
#
registry_external_url 'https://registry.wpquark.io'
registry_nginx['listen_addresses'] = ['139.162.39.232', '192.168.136.224', '[2400:8901::f03c:91ff:fe73:e628]']
registry_nginx['custom_gitlab_server_config'] = "location ^~ /.well-known { root /var/www/regssl; }"
registry_nginx['ssl_certificate'] = "/etc/letsencrypt/live/registry.wpquark.io/fullchain.pem"
registry_nginx['ssl_certificate_key'] = "/etc/letsencrypt/live/registry.wpquark.io/privkey.pem"
Now as you can guess, I have set it up to redirect all certbot request to a custom directory. But certbot, requests from the domain http://registry.wpquark.io/.well-known/...
which gets redirected to https://wpquark.io/.well-known/...
thus failing the attempt.
What is the current bug behavior?
When using https
in the registry domain, non-https requests get redirected to GitLab Domain.
What is the expected correct behavior?
It should get redirected to the Registry Domain, not GitLab Domain.
Output of checks
Results of GitLab environment info
Expand for output related to GitLab environment info
System information System: Ubuntu 16.04 Current User: git Using RVM: no Ruby Version: 2.3.5p376 Gem Version: 2.6.13 Bundler Version:1.13.7 Rake Version: 12.1.0 Redis Version: 3.2.5 Git Version: 2.13.6 Sidekiq Version:5.0.4 Go Version: unknown
GitLab information Version: 10.1.2 Revision: af60a6c Directory: /opt/gitlab/embedded/service/gitlab-rails DB Adapter: postgresql URL: https://wpquark.io HTTP Clone URL: https://wpquark.io/some-group/some-project.git SSH Clone URL: git@wpquark.io:some-group/some-project.git Using LDAP: no Using Omniauth: no
GitLab Shell Version: 5.9.3 Repository storage paths:
- default: /var/opt/gitlab/git-data/repositories Hooks: /opt/gitlab/embedded/service/gitlab-shell/hooks Git: /opt/gitlab/embedded/bin/git
Results of GitLab application Check
Expand for output related to the GitLab application check
root@wpquark:/etc/gitlab# gitlab-rake gitlab:check SANITIZE=true Checking GitLab Shell ...
GitLab Shell version >= 5.9.3 ? ... OK (5.9.3) Repo base directory exists? default... yes Repo storage directories are symlinks? default... no Repo paths owned by git:root, or git:git? default... yes Repo paths access is drwxrws---? default... yes hooks directories in repos are links: ... 4/1 ... ok 4/2 ... ok 4/3 ... ok 4/4 ... ok 11/6 ... ok 12/7 ... ok 2/8 ... ok 2/9 ... ok 4/11 ... ok 4/13 ... ok 4/15 ... ok 2/16 ... ok 4/17 ... ok 4/18 ... ok 71/19 ... ok 70/20 ... ok 4/21 ... ok 4/22 ... ok 2/23 ... ok 70/24 ... ok 2/25 ... ok 70/26 ... ok 4/27 ... ok 71/28 ... ok 70/29 ... ok 71/30 ... ok 4/31 ... ok 4/33 ... ok 4/34 ... ok 41/35 ... ok 2/36 ... ok 4/37 ... ok 4/39 ... ok 2/40 ... repository is empty 4/41 ... ok 2/42 ... ok 4/43 ... ok 2/44 ... ok 65/45 ... ok 65/46 ... ok 65/47 ... ok 65/48 ... ok 70/49 ... ok 4/50 ... ok 65/51 ... ok 70/53 ... ok 71/54 ... ok 68/55 ... ok 71/56 ... ok 72/57 ... ok 72/58 ... ok 73/59 ... ok 71/61 ... ok 2/62 ... ok 2/63 ... ok 71/64 ... ok 4/65 ... ok 2/66 ... ok 68/67 ... ok 4/68 ... ok Running /opt/gitlab/embedded/service/gitlab-shell/bin/check Check GitLab API access: OK Redis available via internal API: OK
Access to /var/opt/gitlab/.ssh/authorized_keys: OK gitlab-shell self-check successful
Checking GitLab Shell ... Finished
Checking Sidekiq ...
Running? ... yes Number of Sidekiq processes ... 1
Checking Sidekiq ... Finished
Reply by email is disabled in config/gitlab.yml Checking LDAP ...
LDAP is disabled in config/gitlab.yml
Checking LDAP ... Finished
Checking GitLab ...
Git configured correctly? ... yes Database config exists? ... yes All migrations up? ... yes Database contains orphaned GroupMembers? ... no GitLab config exists? ... yes GitLab config up to date? ... yes Log directory writable? ... yes Tmp directory writable? ... yes Uploads directory exists? ... yes Uploads directory has correct permissions? ... yes Uploads directory tmp has correct permissions? ... yes Init script exists? ... skipped (omnibus-gitlab has no init script) Init script up-to-date? ... skipped (omnibus-gitlab has no init script) Projects have namespace: ... 4/1 ... yes 4/2 ... yes 4/3 ... yes 4/4 ... yes 11/6 ... yes 12/7 ... yes 2/8 ... yes 2/9 ... yes 4/11 ... yes 4/13 ... yes 4/15 ... yes 2/16 ... yes 4/17 ... yes 4/18 ... yes 71/19 ... yes 70/20 ... yes 4/21 ... yes 4/22 ... yes 2/23 ... yes 70/24 ... yes 2/25 ... yes 70/26 ... yes 4/27 ... yes 71/28 ... yes 70/29 ... yes 71/30 ... yes 4/31 ... yes 4/33 ... yes 4/34 ... yes 41/35 ... yes 2/36 ... yes 4/37 ... yes 4/39 ... yes 2/40 ... yes 4/41 ... yes 2/42 ... yes 4/43 ... yes 2/44 ... yes 65/45 ... yes 65/46 ... yes 65/47 ... yes 65/48 ... yes 70/49 ... yes 4/50 ... yes 65/51 ... yes 70/53 ... yes 71/54 ... yes 68/55 ... yes 71/56 ... yes 72/57 ... yes 72/58 ... yes 73/59 ... yes 71/61 ... yes 2/62 ... yes 2/63 ... yes 71/64 ... yes 4/65 ... yes 2/66 ... yes 68/67 ... yes 4/68 ... yes Redis version >= 2.8.0? ... yes Ruby version >= 2.3.3 ? ... yes (2.3.5) Git version >= 2.7.3 ? ... yes (2.13.6) Git user has default SSH configuration? ... yes Active users: ... 66
Checking GitLab ... Finished