Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do we change the URL of a working GitLab install?

Tags:

gitlab

I have set up and we are running a default install of GitLab v6.0.1 (we're about to upgrade as well). It was a "Production" setup, following this guide precisely to the letter:

https://github.com/gitlabhq/gitlabhq/blob/master/doc/install/installation.md

Now, how do we safely change the URL of a working install?

Apparently our URL is very long and we've come up with a new URL. I've edited a number of configuration files and the "Application Status Checks" report everything is OK. I've rebooted the server to ensure things are still working.

I can access Nginx just fine, over our original SSL. I can browse the GitLab site, create a repository, etc. I can fork and commit just fine.

It all seems to be OK; but, since this is not a native environment for me, I wanted to double check that I have done everything to rename a GitLab site.

The files I've edited are:

/etc/hosts
  127.0.0.1  localhost
  10.0.0.10  wake.domain.com    wake
  10.0.0.10  git.domain.com     git

/home/git/gitlab/config/gitlab.yml
  production: &base
    gitlab:
      host: git.domain.com

/home/git/gitlab-shell/config.yml
  gitlab_url: "https://git.domain.com"
  ^- yes, we are on SSL and that is working, even on a new URL

/etc/nginx/sites-available/gitlab
  server {
    server_name git.domain.com
like image 378
eduncan911 Avatar asked Oct 18 '13 17:10

eduncan911


People also ask

What is the URL of my GitLab instance?

From your browser's address bar, you'll extract https://gitlab.companydomain.com/ whereas the instance URL is gitlab.companydomain.com then. Depending on the desired way to clone from the Git server in GitLab, you'll either use SSH or HTTPS as transport.

What is external URL in GitLab?

external_url "https://example.com/gitlab" In this example, the relative URL under which GitLab is served is /gitlab . Change it to your liking. Reconfigure GitLab: sudo gitlab-ctl reconfigure.

What type of tool does the GitLab install use?

The GitLab application uses PostgreSQL for persistent database information (for example, users, permissions, issues, or other metadata). GitLab stores the bare Git repositories in the location defined in the configuration file, repositories: section.

Where are GitLab settings?

The Settings page in GitLab provides a centralized home for your project configuration options. To access it, go to your project's homepage and, in the left navigation menu, clicking Settings. To reduce complexity, settings are grouped by topic into sections. To display all settings in a section, click Expand.


5 Answers

GitLab Omnibus

For an Omnibus install, it is a little different.

The correct place in an Omnibus install is:

/etc/gitlab/gitlab.rb
    external_url 'http://gitlab.example.com'

Finally, you'll need to execute sudo gitlab-ctl reconfigure and sudo gitlab-ctl restart so the changes apply.


I was making changes in the wrong places and they were getting blown away.

The incorrect paths are:

/opt/gitlab/embedded/service/gitlab-rails/config/gitlab.yml
/var/opt/gitlab/.gitconfig
/var/opt/gitlab/nginx/conf/gitlab-http.conf

Pay attention to those warnings that read:

# This file is managed by gitlab-ctl. Manual changes will be
# erased! To change the contents below, edit /etc/gitlab/gitlab.rb
# and run `sudo gitlab-ctl reconfigure`.
like image 51
Jonathon Reinhart Avatar answered Oct 08 '22 09:10

Jonathon Reinhart


You did everything correctly!

You might also change the email configuration, depending on if the email server is also the same server. The email configuration is in gitlab.yml for the mails sent by GitLab and also the admin-email.

like image 35
Razer Avatar answered Oct 08 '22 10:10

Razer


Actually, this is NOT totally correct. I arrived at this page, trying to answer this question myself, as we are transitioning production GitLab server from http:// to https:// and most stuff is working as described above, but when you login to https://server and everything looks fine ... except when you browse to a project or repository, and it displays the SSH and HTTP instructions... It says "http" and the instructions it displays also say "http".

I found some more things to edit though:

/home/git/gitlab/config/gitlab.yml
  production: &base
    gitlab:
      host: git.domain.com

      # Also edit these:
      port: 443
      https: true
...

and

/etc/nginx/sites-available/gitlab
  server {
    server_name git.domain.com;

    # Also edit these:
    listen 443 ssl;
    ssl_certificate     /etc/ssl/certs/somecert.crt;
    ssl_certificate_key /etc/ssl/private/somekey.key;

...
like image 23
Edward Ned Harvey Avatar answered Oct 08 '22 09:10

Edward Ned Harvey


Do not forget to clear the cache after updating the external_url param in /etc/gitlab/gitlab.rb, otherwise your existing project clone URLs will still be showing your old host name.

A simple 3 step process to change the hostname is as follows

  • update the external_url param in /etc/gitlab/gitlab.rb
  • sudo gitlab-ctl reconfigure
  • sudo gitlab-ctl restart
  • sudo gitlab-rake cache:clear

Ref:

https://forum.gitlab.com/t/clone-url-wont-change/21692/6

like image 38
user728650 Avatar answered Oct 08 '22 09:10

user728650


There are detailed notes on this that helped me completely, located here.

Jonathon Reinhart has already answered with the key bit, to edit /etc/gitlab/gitlab.rb, alter the external_url and then run sudo gitlab-ctl reconfigure; sudo gitlab-ctl restart

However I needed to go a bit further and docs I linked above explained it. So what I ended up with looks like:

external_url 'https://gitlab.toilethumor.com'
nginx['ssl_certificate'] = "/www/ssl/star_toilethumor.com-chained.crt"
nginx['ssl_certificate_key'] = "/www/ssl/star_toilethumor.com.key"
nginx['proxy_set_headers'] = {
 "X-Forwarded-Proto" => "http",
 "CUSTOM_HEADER" => "VALUE"
}

Above, I've explicitly declared where my SSL goodies are on this server. And that's of course followed by

sudo gitlab-ctl reconfigure
sudo gitlab-ctl restart

Also, when you switch the omnibus package to https, the bundled nginx will only serve on port 443. Since all my stuff is reached via reverse proxy, this part was potentially significant.

As I went through this, I screwed something up and it helpful to find the actual nginx logs, this lead me there:

sudo gitlab-ctl tail nginx
like image 45
James T Snell Avatar answered Oct 08 '22 08:10

James T Snell