为了方便外部访问,所以一开始吧gitlab配置成了https,再通过反向代理和TCP隧道从外部网络服务器反向代理到本地应用服务器,由于本地应用服务器和工作的PC在局域网里面,如果这个时候通过通过外部访问仓库就会很鸡肋,而且gitlab runner如果通过https进行注册,有些时候会因为网络问题导致流水线失败。所以这里讲一下这么让gitlab同时开启http和https模式
1、修改Docker暴露端口
将gitlab的443和80都暴露出来
2、将gitlab配置成https模式
1 | nano /etc/gitlab/gitlab.rb |
修改 external_url
1 | ... |
然后执行 gitlab-ctl reconfigure ,此时会在 /var/opt/gitlab/nginx/conf 生成文件gitlab-https.conf \
复制一份出来
1 | cp /var/opt/gitlab/nginx/conf/gitlab-https.conf /var/opt/gitlab/nginx/conf/gitlab-http.conf |
把https的配置文件修改成http的
1 | ... |
把修改完的配置文件include 到 /var/opt/gitlab/nginx/conf/nginx.conf
修改 gitlab.rb 在nginx配置添加
1 | ... |