我们如何更改 GitLab 安装的 URL?

我已经安装好了,我们正在运行 GitLab v6.0.1的默认安装(我们也将进行升级)。这是一个“生产”设置,严格按照这个指南:

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

现在,我们如何安全地更改正常运行的安装的 URL?

显然我们的网址很长,我们想出了一个新的网址。我已经编辑了许多配置文件,“应用程序状态检查”报告一切正常。我重启了服务器,确保一切正常。

我可以通过原始的 SSL 访问 Nginx。我可以浏览 GitLab 站点,创建一个存储库等等。我可以分叉和承诺,只是罚款。

这一切似乎都还好; 但是,由于这不是我的本地环境,我想再次检查我已经做了所有的事情来重命名一个 GitLab 站点。

我编辑的文件是:

/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
153397 次浏览

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.

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;


...

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`.

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

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