1.申请域名和证书 阿里云、腾讯云等,申请域名,并未此域名申请证书 2.下载证书 实名认证后,阿里云签发证书后,下载证书 gitlab使用nginx做反向代理,所以证书for nginx。下载后重命名如下 3.配置gitlab
vim /etc/gitlab/gitlab.rb external_url 'https://cloud.cn' nginx['enable'] = true nginx['redirect_http_to_https'] = true #http重定向到https nginx['redirect_http_to_https_port'] = 80 nginx['redirect_http_to_https'] = true #http重定向到https,使用http的访问会自动重定向到https; nginx['redirect_http_to_https_port'] = 80其余的配置其实都不需要,包括:
nginx['ssl_certificate'] = "/etc/gitlab/ssl/server.crt" /var/opt/gitlab/nginx/conf/gitlab-http.conf4.上传证书到服务器,地址:/etc/gitlab/ssl 5.重配置gitlab
sudo gitlab-ctl reconfigure //本部分会修改gitlab配置,包括上述提到的nginx配置文件6.重启gitlab sudo gitlab-ctl restart