1 工具 一台具有公网ip的服务器
2 下载frp frp下载地址
打开上面的frp下载地址
在这里插入图片描述

公网服务器上 打开下载文件

frps是服务端,在公网服务器上部署

frpc是客户端,在需要内网穿透的电脑上部署

1. frps配置 首先我这用的是win公网服务器 (linux和mac同样是编辑这个文件)里面的frps.ini文件

在这里插入图片描述

[common]
bind_addr = 0.0.0.0
bind_port = 2534
subdomain_host = xxx.xxx.xxx
token =Y2SEsBABxxx

dashboard_port = 16343
dashboard_user = yjx
dashboard_pwd = yjx

vhost_http_port = 1208

log_file = ./frps.log
log_level = error
log_max_days = 3
max_pool_count = 500
tcp_mux = true

阿里云解析配置
我是用的家里的路由器自动获取动态公网ip并更新到阿里云 云解析
在这里插入图片描述

需要修改的数据
bind_port = 2534 # 公网服务器爆漏的端口
subdomain_host = xxx.xxx.xxx #公网ip或者域名(访问多个web端必须使用域名,我用的域名,通过二级域名访问不同的本地web端(作用类似ngins里面的service_name),列bt40.xxx.xxx.xxx:1208, ng40.xxx.xxx.xxx:1208, kuboard40.xxx.xxx.xxx:1208)
token =Y2SEsBxxx #

dashboard_port = 16343 #frp服务器管理(可以看当前连接的服务)
dashboard_user = yjx #登录名
dashboard_pwd = yjx #登录密码

vhost_http_port = 1208 # web端爆漏的端口

修改frps.ini配置后启动 到cmd同目录执行

win版
 frps.exe -c frps.ini
 
mac版
./frps -c ./frps.ini

2. 启动好frps服务器后,在配置frpc客户端

打开
在这里插入图片描述

[common]
server_addr = xxx.xxx.xxx
server_port = 2524
token =Y2SEsBABxxx

[web01]
type = http
local_ip = 127.0.0.1
local_port = 88
custom_domains = bt40.xxx.xxx.xxx
locations = /
	
[web02]
type = http
local_ip = 127.0.0.1
local_port = 8
custom_domains = ng40.xxx.xxx
locations = /

[web03]
type = http
local_ip = 127.0.0.1
local_port = 30080
custom_domains = kuboard40.xxx.xxx
locations = /


[ssh]
type = tcp
local_port = 22
local_ip = 127.0.0.1
# 在服务端注册端口 服务端将监听 7022 ssh root@xxx.xxx.xxx -p 7022 即可代理到本机 ssh 登录
remote_port = 7022

[mysql]
type = tcp
local_ip = 127.0.0.1
local_port = 3306
remote_port = 6001

[redis]
type = tcp
local_ip = 127.0.0.1
local_port = 6379
remote_port = 6002

server_addr = xxx.xxx.xxx 必须和frps.ini的 subdomain_host 一致
server_port = 2524 必须和frps.ini的 bind_port 一致
token =Y2SEsBABxxx 必须和frps.ini的 token 一致

修改frpc.ini配置后启动 到cmd同目录执行

win版
 frpc.exe -c frpc.ini
 
mac版
./frpc -c ./frpc.ini

内网穿透即可完成

通过公网域名 xxx.xxx.xxx:6002 就可连接到本地的redis服务器
通过公网域名 xxx.xxx.xxx:6001 就可连接到本地的mysql服务器
通过公网域名 kuboard40.xxx.xxx:1208 就可访问本地的kuboard web端

3 查看当前使用用户连接,只能看看使用的用户连接,作用不大

通过xxx.xxx.xxx:16343查看当前所有内网穿透用户连接 16343是frps.ini里面配置的dashboard_port = 16343
密码账户是frps.ini 里面的。可以随便改
dashboard_user = yjx
dashboard_pwd = yjx

在这里插入图片描述

我丢,刚搭建好frp 又看到了更好用的nps
在这里插入图片描述

ngrok
https://github.com/inconshreveable/ngrok

frp
https://github.com/fatedier/frp

lanproxy
https://github.com/ffay/lanproxy

goproxy
https://github.com/snail007/goproxy

nps
https://github.com/cnlh/nps

综合比较后发现nps比较符合需求,但是目前版本(0.23)存在稳定性问题,作者打算在未来版本收费

更好用的nps nps教程

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐