在 Debian 上给 GitLab 配置 SSL(HTTPS),通常有两种常见方式:
gitlab.example.com)编辑配置文件:
sudo vim /etc/gitlab/gitlab.rb
修改或添加以下内容:
external_url 'https://gitlab.example.com'
letsencrypt['enable'] = true
letsencrypt['contact_emails'] = ['admin@example.com']
letsencrypt['auto_renew'] = true
sudo gitlab-ctl reconfigure
GitLab 会自动:
浏览器访问:
https://gitlab.example.com
通常需要:
gitlab.example.com.crtgitlab.example.com.key放到安全目录(如):
/etc/gitlab/ssl/
sudo vim /etc/gitlab/gitlab.rb
external_url 'https://gitlab.example.com'
nginx['ssl_certificate'] = "/etc/gitlab/ssl/gitlab.example.com.crt"
nginx['ssl_certificate_key'] = "/etc/gitlab/ssl/gitlab.example.com.key"
如果是泛域名或中间证书:
nginx['ssl_certificate'] = "/etc/gitlab/ssl/fullchain.crt"
sudo gitlab-ctl reconfigure
sudo ufw allow 443
sudo ufw allow 80
默认 GitLab 已开启,如未生效可加:
nginx['redirect_http_to_https'] = true
sudo gitlab-ctl tail nginx
Let’s Encrypt 会自动续期
手动测试:
sudo gitlab-rake letsencrypt:renew
如果你告诉我:
我可以给你更精确的配置示例。