gitlab同时保留http和https的配置过程
浏览量:878
随着企业安全等级意识提高的需求越来越强力,给gitlab私有仓库部署ssl证书的需求也越来越多,但是受限于一些git版本不支持https或者某些项目的特殊需求,要求gitlab同时保留http和https。
我们知道gitlab原生自带nginx模块,gitlab启动的时候这个模块就会启动起来,占用了80端口(gitlab默认以http的方式访问),但是当我们修改成https访问的时候gitlab会自动把http的访问请求转到https,这样我们要求gitlab同时支持http和https的需求就无法直接完成,需要做一部分修改。
一:外面用nginx再做一层代理。这中实现方式稍显复杂,且两次层nginx转发可能会有冲突(可自行研究,本处不做描述)
二、直接使用gitlab的nginx做相关操作
1、修改gitlab配置文件
$ vim /etc/gitlab/gitlab.rb # external_url 'https://ip:port' # nginx['ssl_certificate'] = "/yourdir/****.pem" nginx['ssl_certificate_key'] = "/yourdir/****.key"
2、重建配置
$ gitlab-ctl reconfigure
此时能正常通过https访问,
3、 拷贝一份新的gitlab的nginx配置文件,并修改http.conf中的端口 和upstream gitlab-workhorse修改为 *:80 和 upstream gitlab-workhorses
$ cp /var/opt/gitlab/nginx/conf/gitlab-http.conf /var/opt/gitlab/nginx/conf/http.conf
4、修改/var/opt/gitlab/nginx/conf/nginx.conf文件
$ vim /var/opt/gitlab/nginx/conf/nginx.conf include /var/opt/gitlab/nginx/conf/http.conf #添加这一行
5、重启nginx
$ gitlab-ctl restart nginx
注意:是重启 不是重载配置
因gitlab版本问题可能导致某些nginx启动失败,若配置过程遇到问题,可查看/var/log/gitlab/nginx/error.log
>>>>>>>>>>>>>>>>>>
执行Git命令拉取https时出现 SSL certificate problem 的解决办法
方法如下:
1.创建临时环境变量:
windows上命令行输入:
$ set GIT_SSL_NO_VERIFY=true
Linux下:
$ export GIT_SSL_NO_VERIFY=1
这里clone可以根据需要换成其他的git命令。
也可以把临时环境变量变为永久的,反正永远不验证ssl证书也没什么风险吧。。。
2.用git自带的配置命令:
$ git config --global http.sslVerify false

神回复
发表评论:
◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。