3

we have a gitlab instance in Docker, we migrate recently to this instance from another deployed with helm Chart, and I would like to run Gitlab with two urls the recent and the alias i was created for the old in LB, to avoid changing so many parametres whithin gitlab config.

2 Answers 2

4

It's currently not supported. You may be interested in following this issue: https://gitlab.com/gitlab-org/gitlab/-/issues/21319

As a workaround you could probably try using some proxy in between that would rewrite URL's or simply redirect from old URL to the new one

Sign up to request clarification or add additional context in comments.

Comments

3

GitLab does not provide for being operated with more than one domain.

I needed a solution for this myself as well. Since the domain of my organization changed, GitLab had to be moved to a new domain, but at the same time GitLab should remain temporarily accessible via the old domain - to allow a smooth transition.

The parameter external_url defines the (main) domain for GitLab. This domain is the basis for many things, e.g. for the repository clone URL. When GitLab requests a certificate via Let's Encrypt, it does so for this domain.

GitLab uses an nginx server for HTTP/HTTPS delivery and you can manually give nginx additional configuration.

My workaround - step by step

  1. Directory for additional nginx config created
    mkdir /etc/gitlab/nginx-additional-conf.d/

  2. copied previous GitLab config for old domain
    cp /var/opt/gitlab/nginx/conf/gitlab-http.conf /etc/gitlab/nginx-additional-conf.d/old-domain.disabled

  3. Configured GitLab to the new domain and enabled the additional nginx config (in gitlab.rb)

    external_url 'https://gitlab.newdomain.org'
    nginx['custom_nginx_config'] = "include /etc/gitlab/nginx-additional-conf.d/*.conf;"
    
  4. GitLab reconfigured
    gitlab-ctl reconfigure

  5. additional nginx config checked (especially parameters server_name, ssl_certificate and ssl_certificate_key) and enabled by renaming
    mv /etc/gitlab/nginx-additional-conf.d/old-domain.{disabled,conf}

  6. restart nginx server
    gitlab-ctl restart nginx

Result

I see this as a temporary solution, because GitLab outputs the new domain everywhere, yet via the manual nginx config GitLab is still accessible via the old domain, especially the GitLab WebGUI as well as the pull/push via HTTPS are still possible. If GitLab displays the domain at any point, it will always output the new domain, regardless of which domain is used to access GitLab.

SSH (clone/pull/push) are not affected by all this, this depends only on the DNS configuration and the SSH server.

Problems with this solution

  • GitLab does not independently take care of the SSL certificate of the old domain, the SSL certificate must be manually requested or manually provisioned on the server.
  • The manual nginx configuration is not automatically adjusted, especially during/after GitLab updates.

Alternative with 301 forwarding

Alternatively, the additional nginx config can be used to simply 301 forward to the new domain, but in this case the Git clients are "a bit confused" with HTTPS pull/push operations and issue warnings.

I have not finally and conclusively tested this variant.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.