1 工具 一台具有公网ip的服务器
2 下载frp frp下载地址
打开上面的frp下载地址
公网服务器上 打开下载文件
frps是服务端,在公网服务器上部署
frpc是客户端,在需要内网穿透的电脑上部署
1. frps配置 首先我这用的是win公网服务器 (linux和mac同样是编辑这个文件)里面的frps.ini文件
[common]bind_addr = 0.0.0.0bind_port = 2534subdomain_host = xxx.xxx.xxxtoken =Y2SEsBABxxxdashboard_port = 16343dashboard_user = yjxdashboard_pwd = yjxvhost_http_port = 1208log_file = ./frps.loglog_level = errorlog_max_days = 3max_pool_count = 500tcp_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.inimac版./frps -c ./frps.ini
2. 启动好frps服务器后,在配置frpc客户端
打开
[common]server_addr = xxx.xxx.xxxserver_port = 2524token =Y2SEsBABxxx[web01]type = httplocal_ip = 127.0.0.1local_port = 88custom_domains = bt40.xxx.xxx.xxxlocations = /[web02]type = httplocal_ip = 127.0.0.1local_port = 8custom_domains = ng40.xxx.xxxlocations = /[web03]type = httplocal_ip = 127.0.0.1local_port = 30080custom_domains = kuboard40.xxx.xxxlocations = /[ssh]type = tcplocal_port = 22local_ip = 127.0.0.1# 在服务端注册端口 服务端将监听 7022 ssh root@xxx.xxx.xxx -p 7022 即可代理到本机 ssh 登录remote_port = 7022[mysql]type = tcplocal_ip = 127.0.0.1local_port = 3306remote_port = 6001[redis]type = tcplocal_ip = 127.0.0.1local_port = 6379remote_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.inimac版./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
/inconshreveable/ngrok
frp
/fatedier/frp
lanproxy
/ffay/lanproxy
goproxy
/snail007/goproxy
nps
/cnlh/nps
综合比较后发现nps比较符合需求,但是目前版本(0.23)存在稳定性问题,作者打算在未来版本收费
更好用的nps nps教程