下面按最常见场景给你说明:在 Linux 服务器上部署的 GitLab(Omnibus 安装)如何绑定域名。
/etc/gitlab/gitlab.rb)git.example.com)sudo vim /etc/gitlab/gitlab.rb
external_url 'http://git.example.com'
如果要 HTTPS:
external_url 'https://git.example.com'
sudo gitlab-ctl reconfigure
在你的域名服务商处添加:
| 类型 | 主机记录 | 值 |
|---|---|---|
| A | git | 服务器公网 IP |
示例:
git.example.com → 1.2.3.4
等待生效(通常几分钟到几十分钟)
GitLab 默认使用自带 Nginx,一般不用额外配置。
如需修改端口:
nginx['listen_port'] = 80
letsencrypt['enable'] = true
letsencrypt['contact_emails'] = ['admin@example.com']
然后:
sudo gitlab-ctl reconfigure
nginx['enable'] = false
web_server['external_users'] = ['www-data']
外部 Nginx 示例:
server {
listen 80;
server_name git.example.com;
location / {
proxy_pass http://127.0.0.1:8080;
}
}
浏览器访问:
http://git.example.com
或
https://git.example.com
如果你告诉我:
我可以给你更精确的配置示例。