环境准备:
frp安装包 frp_0.44.0_linux_amd64.tar.gz
私有gitlab:192.168.1.10:8999
以下简称server01
云服务器:有公网ip的任意服务器
以下简称server02
一、上传frp安装包分别到server01和server02并解压
[root@localhost ~]# rz -be
ZMODEM Session started 694
------------------------
Sent frp_0.44.0_linux_amd64.tar.gz
[root@localhost ~]# tar -zxvf frp_0.44.0_linux_amd64.tar.gz -C /usr/local/ #解压到/usr/local 目录
frp_0.44.0_linux_amd64/
frp_0.44.0_linux_amd64/frpc.ini
frp_0.44.0_linux_amd64/LICENSE
frp_0.44.0_linux_amd64/frpc
frp_0.44.0_linux_amd64/frpc_full.ini
frp_0.44.0_linux_amd64/frps.ini
frp_0.44.0_linux_amd64/frps
frp_0.44.0_linux_amd64/frps_full.ini
[root@localhost ~]#
[root@localhost ~]# cd /usr/local/
[root@localhost local]# mv frp_0.44.0_linux_amd64/ frp #更改文件夹名为frp
server02服务器同上
二、修改配置文件
server01: frpc.ini 配置文件名
server02: frps.ini 配置文件名
vim frpc.ini #server01
[common]
server_addr = server02公网ip
server_port = 7000
[ssh]
type = tcp
local_ip = 192.168.1.10
local_port = 22
remote_port = 2222
# gitlab http映射
[gitlab_http]
type = tcp
local_ip = 192.168.1.10
local_port = 8999
remote_port = 8999
vi frps.ini #server02
[common]
bind_port = 7000
dashboard_port = 7500
dashboard_user = admin
dashboard_pwd = admin
enable_prometheus = true
# frp config
log_file = /var/log/frps.log
log_level = info
log_max_days = 3
三、启动frp服务
server01
[root@localhost frp]# sudo ./frpc
2022/09/25 05:26:36 [I] [service.go:349] [28dba5c3338f9d43] login to server success, get run id [28dba5c3338f9d43], server udp port [0]
2022/09/25 05:26:36 [I] [proxy_manager.go:144] [28dba5c3338f9d43] proxy added: [ssh gitlab_http]
2022/09/25 05:26:36 [I] [control.go:181] [28dba5c3338f9d43] [ssh] start proxy success
2022/09/25 05:26:36 [I] [control.go:181] [28dba5c3338f9d43] [gitlab_http] start proxy success
server02
[root@VM-24-16-centos frp]# sudo ./frps
2022/09/25 20:58:45 [I] [root.go:211] frps uses command line arguments for config
2022/09/25 20:58:45 [I] [service.go:194] frps tcp listen on 0.0.0.0:7000
2022/09/25 20:58:45 [I] [root.go:218] frps started successfully
2022/09/25 20:58:57 [I] [service.go:450] [28dba5c3338f9d43] client login info: ip [************] version [0.44.0] hostname [] os [linux] arch [amd64]
2022/09/25 20:58:57 [I] [tcp.go:64] [28dba5c3338f9d43] [ssh] tcp proxy listen port [2222]
2022/09/25 20:58:57 [I] [control.go:465] [28dba5c3338f9d43] new proxy [ssh] type [tcp] success
2022/09/25 20:58:57 [I] [tcp.go:64] [28dba5c3338f9d43] [gitlab_http] tcp proxy listen port [8999]
2022/09/25 20:58:57 [I] [control.go:465] [28dba5c3338f9d43] new proxy [gitlab_http] type [tcp] success
注意server01关闭防火墙
server02 开放端口
四、访问gitlab服务
地址 server02+gitlab端口
六、测试代码 clone、push
验证:
更多frp使用请查看frp项目 https://github.com/fatedier/frp
版权声明:本文为weixin_45361164原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。