.初心仅为个人记录参考,如有不对望各位指出
1.搭建gitlab版本管理仓库
具体gitlab搭建具体过程:参考.谷神通
添加gitlab镜像
1 | wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-10.0.0-ce.0.el7.x86_64.rpm |
安装gitlab
1 | rpm -i gitlab-ce-10.0.0-ce.0.el7.x86_64.rpm |
修改gitlab配置文件
1 2 3 4 | vim /etc/gitlab/gitlab.rb #修改配置地址如下(默认80端口,修改其他端口的满足条件:未被其他应用占用): external_url 'http://192.168.31.229' //我这里是ifconfig下本地ip地址,127.0.01也是可以的 |
更新配置
1 | gitlab-ctl reconfigure |
重启gitlab
1 | gitlab-ctl restart |
访问gitlab页面
1 | http://192.168.31.229 |
ps:
a. 刚开始启动可能比较慢,访问gitlab地址报错502之类的,建议耐心等下先。
b. gitlab的内存占用大概3g,我老笔记本只有4g,后面会更新优化gitlab的配置使其占用内存降低 【提醒自己别忘记后面补充完整优化配置】
2.通过frp公网访问gitlab
准备已经认证备案的(www.xxx.com)域名,创建二级域名
1 | gitlab.xxx.com |
在server.LINUX的frps.ini 新增如下配置:
1 | vhost_http_port = 7456 |
在client.LINUX的frpc.ini新增如下配置:
1 2 3 4 | [web-gitlab.xxx.com] type = http local_port = 80 custom_domains = gitlab.xxx.com |
公网访问内网gitlab地址:
1 | http://gitlab.xxx.com:7456 |
–> 但是这样的方式访问有一点不那么友好!!! 强迫症不允许!!!
在server.LINUX的安装nginx,配置文件新增如下:
1 2 3 4 5 6 7 8 9 10 | server { listen 80; server_name gitlab.xxx.com; location / { proxy_set_header X-Real-IP $remote_addr; proxy_set_header Host $http_host; #因为server.LINUX中frp已经配置v_host_port,该端口访问直接tcp到client.LINUX的对应内网服务 proxy_pass http://127.0.0.1:7456; } } |
这样就可以直接通过二级域名访问到内网的gitlab服务了yeah!
–> 你以为问题就这样简单的结束了吗? 天真啊 骚年
回顾到创建gitlab
修改gitlab配置文件
1 2 | vim /etc/gitlab/gitlab.rb external_url 'http://192.168.31.229' |
这里若配置ip,那么你项目的访问地址默认是你配置的ip地址

修改gitlab配置文件,依次执行以下操作
1 2 3 4 5 6 7 | vim /etc/gitlab/gitlab.rb external_url 'http://gitlab.xxx.com' gitlab-ctl reconfigure gitlab-ctl restart |
修改client.LINUX的host文件
1 2 3 4 | vim /etc/hosts #新增 192.168.31.229 gitlab.xxx.com |
然后启动后gitlab的项目配置就正常显示了

注意:在使用ssh非http方式gitClone项目的时候,需要在内网的client.LINIUX的frpc.ini增加如下配置;同时需要开启aliyun的安全组打开22端口
1 2 3 4 5 | [ssh-gitlab] type = tcp local_ip = 127.0.0.1 remote_port = 22 local_port = 22 |