GitLab配置`https`链接
GitLab配置https
链接
需求:队自建的gitlab在内网内运行,ip为192.168.1.90,现增加https链接,保证代码安全。
-
申请域名和证书:
至阿里云申请域名,cloud.cn,并申请为本域名使用的证书,友情提示:有免费证书可以使用。
-
下载证书:
实名认证之后,阿里签发证书后,即可下载证书:gitlab使用nginx做反向代理,顾下载证书for nginx,下载之后有两个文件,
在为gitlab配置证书的时候,我们是使用crt的证书,直接重命名pem文件为,my.crt即可。
-
配置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.conf
-
将证书上传服务器:地址:
/etc/gitlab/ssl/
-
重配置gitlab!必选
# sudo gitlab-ctl reconfigure //本部分会修改gitlab配置,包括上述提到的nginx配置文件
-
重启gitlab:
# sudo gitlab-ctl restart
配置完成