Install GitLab under a relative URL
While we recommend to install GitLab on its own (sub)domain, sometimes
this is not possible due to a variety of reasons. In that case, GitLab can also
be installed under a relative URL, for example
This document describes how to run GitLab under a relative URL for installations from source. If you are using an Omnibus package, the steps are different. Use this guide along with the installation guide if you are installing GitLab for the first time.
There is no limit to how deeply nested the relative URL can be. For example you
could serve GitLab under
/foo/bar/gitlab/git without any issues.
Changing the URL on an existing GitLab installation, changes all remote URLs, so you have to manually edit them in any local repository that points to your GitLab instance.
The list of configuration files you must change to serve GitLab from a relative URL is:
After all the changes, you must recompile the assets and restart GitLab.
Relative URL requirements
See the requirements document for more information.
Enable relative URL in GitLab
Before following the steps below to enable relative URL in GitLab, some assumptions are made:
- GitLab is served under
- The directory under which GitLab is installed is
Make sure to follow all steps below:
Optional. If you run short on resources, you can temporarily free up some memory by shutting down the GitLab service with the following command:
sudo service gitlab stop
cp /home/git/gitlab/config/initializers/relative_url.rb.sample \ /home/git/gitlab/config/initializers/relative_url.rb
and change the following line:
config.relative_url_root = "/gitlab"
/home/git/gitlab/config/gitlab.ymland uncomment/change the following line:
/home/git/gitlab/config/puma.rband uncomment/change the following line:
ENV['RAILS_RELATIVE_URL_ROOT'] = "/gitlab"
/home/git/gitlab-shell/config.ymland append the relative path to the following line:
Make sure you have copied either the supplied systemd services, or the init script and the defaults file, as stated in the installation guide. Then, edit
/etc/default/gitlaband set in
-authBackendsetting to read like:
-authBackend http://127.0.0.1:8080/gitlabIf you are using a custom init script, make sure to edit the above GitLab Workhorse setting as needed.
Restart GitLab for the changes to take effect.
Disable relative URL in GitLab
To disable the relative URL:
Follow the same as above starting from 2. and set up the GitLab URL to one that doesn’t contain a relative path.