标题 简介 类型 公开时间
关联规则 关联知识 关联工具 关联文档 关联抓包
参考1(官网)
参考2
参考3
详情
[SAFE-ID: JIWO-2024-2624]   作者: ecawen 发表于: [2020-03-29]

本文共 [414] 位读者顶过

开发过程中,很多时候我们需要用到内网穿透,将自己的服务器映射到外网,下面说一下怎么用frps搭建自己的内网穿透服务器[出自:jiwo.org]

frps Github地址 里面有中文文档,大家可以参考。

服务器搭建

  • 服务器搭建
    服务器是阿里云ECS CenterOS CentOS 7.4 64位
    下载frps服务器文件: 下载地址
    选择frp_0.21.0_linux_amd64.tar.gz,如果你是其他操作系统,请自行选择
    下载完之后,传到ECS上,然后解压,编辑frps.ini配置文件
[common] # 服务器端端口  bind_port = 7000 # 客户端连接凭证  privilege_token = fxl421125 # 最大连接数  max_pool_count = 5 # 客户端映射的端口  vhost_http_port = 80 # 服务器看板的访问端口  dashboard_port = 7500 # 服务器看板账户  dashboard_user = admin dashboard_pwd = fxl123

设置完以上配置,保存退出,然后启动服务器

./frps -c ./frps.ini

启动之后查看日志, 提示Start frps success基本上就启动成功

2018/09/04 11:02:49 [I] [service.go:130] frps tcp listen on 0.0.0.0:7000
2018/09/04 11:02:49 [I] [service.go:172] http service listen on 0.0.0.0:8080
2018/09/04 11:02:49 [I] [root.go:207] Start frps success


客户端搭建

客户端是通常是windows
下载frps客户端文件: 下载地址
选择frp_0.21.0_windows_amd64.zip 64位文件
然后解压,配置frpc.ini文件,配置如下:

[common] # 服务器地址 server_addr = 59.110.161.180 # 服务器端口 server_port = 7000 # 服务器连接凭证 privilege_token = fxl123

[web] privilege_mode = true remote_port = 6000 type = http local_ip = 127.0.0.1 # 本地映射的端口 local_port = 80 use_gzip = true # 绑定域名 域名需要配置好解析,解析到服务器 custom_domains = manager.fanxl.cn

命令行启动客户端

frpc.exe -c frpc.ini
F:\Program Files\frp_0.21.0_windows_amd64>frpc.exe -c frpc.ini
2018/09/04 11:39:09 [I] [proxy_manager.go:300] proxy removed: []
2018/09/04 11:39:09 [I] [proxy_manager.go:310] proxy added: [web]
2018/09/04 11:39:09 [I] [proxy_manager.go:333] visitor removed: []
2018/09/04 11:39:09 [I] [proxy_manager.go:342] visitor added: []
2018/09/04 11:39:09 [I] [control.go:246] [883f61e2422ed3f3] login to server success, get run id [883f61e2422ed3f3], server udp port [0]
2018/09/04 11:39:09 [I] [control.go:169] [883f61e2422ed3f3] [web] start proxy success

看到如下信息 start proxy success 说明连接成功,此时可以通过7500端口访问服务器的控制面板页面,查看连接情况
客户端可以新建一个start.bat文件,把启动命令放在里面,这样每次直接运行bat文件即可

服务器服务后台运行及自动启动

使用systemd配置开机自启,适用于 centos7 Ubuntu 16 或 debian 8。

vi /etc/systemd/system/frps.service 新建此文件,并写入以下内容:

[Unit] Description=frps daemon After=syslog.target network.target Wants=network.target [Service] Type=simple ExecStart=/home/developer/frp_0.21.0_linux_amd64/frps -c /home/developer/frp_0.21.0_linux_amd64/frps.ini Restart= always RestartSec=1min [Install] WantedBy=multi-user.target

启动并设为开机自启。

systemctl start frps //启动

systemctl status frps //状态查询

systemctl enable frps //开机启动

补充一下:

ExecStart=/home/developer/frp_0.21.0_linux_amd64/frps.ini

ExecStart=后面这个是frps文件和配置文件


评论

暂无
发表评论
 返回顶部 
热度(414)
 关注微信