下面以 CentOS 7/8 + 官方 GitLab(Omnibus 安装) 为例,说明如何给 GitLab 配置 HTTPS / SSL。
你可以选择:
GitLab 自带 Let’s Encrypt 支持。
例如:
gitlab.example.com.crtgitlab.example.com.key编辑配置文件:
sudo vi /etc/gitlab/gitlab.rb
external_url 'https://gitlab.example.com'
注意:必须是
https
letsencrypt['enable'] = true
letsencrypt['auto_renew'] = true
letsencrypt['contact_emails'] = ['admin@example.com']
nginx['ssl_certificate'] = "/etc/gitlab/ssl/gitlab.example.com.crt"
nginx['ssl_certificate_key'] = "/etc/gitlab/ssl/gitlab.example.com.key"
证书目录需存在:
sudo mkdir -p /etc/gitlab/ssl
sudo chmod 600 /etc/gitlab/ssl/*
sudo gitlab-ctl reconfigure
确保放行:
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload
浏览器访问:
https://gitlab.example.com
无证书警告即成功 ✅
GitLab 默认使用 80 / 443
查看日志:
sudo gitlab-ctl tail nginx
如果你告诉我:
我可以给你更精确的步骤。