1、背景
由于公司安全部門(mén)整活,需要將gitlab配置https。所以有了這篇文章——將http的gitlab配置ssl證書(shū),使其自動(dòng)跳轉(zhuǎn)https訪問(wèn)
2、方法
方法1、直接配置
gitlab會(huì)自動(dòng)生成證書(shū)(由于自建證書(shū),瀏覽器會(huì)提示不安全)
[root@localhost ssl]# vim /etc/gitlab/gitlab.rb
external_url 'https://gitlab.example.com' ###改為https開(kāi)頭
nginx['enable'] = true
nginx['client_max_body_size'] = '2048m'
nginx['redirect_http_to_https'] = true #取消#號(hào) 更改注釋并為true
nginx['ssl_certificate'] = "/etc/gitlab/ssl/gitlab.example.com.crt" #更改路徑
nginx['ssl_certificate_key'] = "/etc/gitlab/ssl/gitlab.example.com.key" #更改路徑
###注意如果使用docker,這里的路徑,需要是docker內(nèi)證書(shū)的路徑
[root@localhost ssl]# mkdir /etc/gitlab/ssl

之后,重新配置
[root@localhost ssl]# gitlab-ctl reconfigure
#如果docker部署也可
[root@localhost ssl]# docker restart gitlab
方法2、使用阿里云證書(shū)
阿里云創(chuàng)建下載nginx證書(shū)
解壓得到pem文件和key文件
放到/etc/gitlab/ssl 目錄后,使用如下命令,使用pem文件生成gitlab所需的crt格式證書(shū)
[root@localhost ssl]# openssl x509 -outform pem -in gitlab.zjiec.com.pem -out gitlab.zjiec.com.crt
剩余步驟按方法1操作即可
最終效果

3、其他問(wèn)題
如果git clone遇到報(bào)錯(cuò)
① fatal: unable to access 'https://gitlab.example.com/.git/': SSL certificate problem: unable to get local issuer certificate
這個(gè)是由于Git默認(rèn)開(kāi)啟了SSL驗(yàn)證,關(guān)閉即可
git config --global http.sslVerify false
② 配置完了記得和開(kāi)發(fā)團(tuán)隊(duì)說(shuō)一下,不然可能會(huì)炸,哈哈哈(編譯器里的url,可能也需要改一下,不然可能驗(yàn)證失?。?/p>
4、參考鏈接
《Gitlab搭建詳細(xì)步驟》https://blog.csdn.net/qq_15290209/article/details/126230624文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-467376.html
《Git出現(xiàn)SSL certificate problem》https://blog.csdn.net/Goals1989/article/details/106895801文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-467376.html
到了這里,關(guān)于Gitlab https(ssl證書(shū))的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!