Recently, I had the problem of moving my GitLab installation from one URL to another. I guess the problem will hit many people every once in a while. On StackOverflow, someone posted half of the answer.

Make a backup and stop GitLab first! Then:

Quote:

  1. In your application.rb file:

    config.relative_url_root = "/gitlab"
    
  2. In your gitlab.yml file:

    relative_url_root: /gitlab
    
  3. In your unicorn.rb:

    ENV["RAILS_RELATIVE_URL_ROOT"] = "/gitlab"
    

You also need to re-configure your web server appripriately.

Now... that does part of the job, but after doing it, I could not properly reach nor use my GitLab site. The two remaining issues are (a) adjusting the URLs in the database, and (b) updating the assets cache. Here are the remaining bits, assuming that you are on MySQL (adapt for other database engines, accordingly):

mysql> update events set data = replace(data, "http://1.1.1.1/", "http://1.1.1.1/gitlab/");

Next, as the appropriate user, do this:

$ rake gitlab:satellites:create RAILS_ENV=production
$ rake assets:clean RAILS_ENV=production
$ rake assets:precompile RAILS_ENV=production

Then restart GitLab.

If you omit the recompiling of the assets, that will yield you broken icons, or, if you simply deleted them, a lot of 502s, until Rails was able to compile them.

At this point, you have access to your projects using the web, but SSH access does not yet work. You will see "Access denied" message. To fix that, you have to update your gitlab-shell configuration. Then put this in your config.yml:

gitlab_url: "http://1.1.1.1/gitlab"

This URL must reflect the new URL you have chosen. After that, re-install gitlab-shell.

Thanks to <rikurrr> for the idea of directly looking into the database.