在 Debian 上设置 GitLab 的域名,通常分为修改 GitLab 配置和配置 DNS / 反向代理两部分。下面按常见场景说明。
sudo nano /etc/gitlab/gitlab.rb
找到或添加以下配置:
external_url 'https://gitlab.example.com'
如果是 HTTP:
external_url 'http://gitlab.example.com'
sudo gitlab-ctl reconfigure
sudo gitlab-ctl restart
在你的域名服务商处添加记录:
A gitlab.example.com -> 服务器公网IP
192.168.1.100 gitlab.example.com
在 gitlab.rb 中:
letsencrypt['enable'] = true
letsencrypt['contact_emails'] = ['admin@example.com']
然后:
sudo gitlab-ctl reconfigure
nginx['ssl_certificate'] = "/etc/gitlab/ssl/gitlab.example.com.crt"
nginx['ssl_certificate_key'] = "/etc/gitlab/ssl/gitlab.example.com.key"
如果你不是用 GitLab 自带 Nginx:
nginx['enable'] = false
gitlab_rails['trusted_proxies'] = ['127.0.0.1']
web_server['external_users'] = ['www-data']
GitLab 会根据 external_url 自动生成:
git@gitlab.example.com:group/project.git
无需额外配置。
sudo gitlab-ctl tail nginx
external_url 'https://gitlab.example.com:8080'
如果你能告诉我:
我可以给你更精确的配置示例。