搭建自己的内网穿透,告别ngrok速度慢的问题,调试本地服务(两种方式,源码部署或者部署包部署,新手直接部署包部署)
内网穿透frp
frp 是一个专注于内网穿透的高性能的反向代理应用,支持 TCP、UDP、HTTP、HTTPS 等多种协议。可以将内网服务以安全、便捷的方式通过具有公网 IP 节点的中转暴露到公网。
golang源码部署
- 下载源码
- 配置客户端
- 在frpc 目录下面添加配置文件 frpc.ini
[common] server_addr = xx.xx.xx.xx 注意替换成自己的服务器公网ip端口 server_port = 7000 [web01] type = http #访问协议 内网端口 local_port = 8181
#内网web服务的端口号,也就是我们想展示的页面的端口号
custom_domains = xx.xx.xx.xx 注意替换成自己的服务器公网ip端口
- 配置服务端
```go
[common]
bind_port = 7000
#与客户端绑定的进行通信的端口
vhost_http_port = 9098
#访问客户端web服务自定义的端口号,也就是最终用公网ip访问时的端口号
#./frps -c frps.ini
#GOOS=linux GOARCH=amd64 go build -o frps *.go 打包部署到服务器
- 最终目录结构
测试效果
1.启动服务端,在fprs 目录线面运行go run *.go -c ./frps.ini 2021/07/06 15:14:07 [I] [root.go:200] frps uses config file: ./frps.ini 2021/07/06 15:14:07 [I] [service.go:192] frps tcp listen on 0.0.0.0:7000 2021/07/06 15:14:07 [I] [service.go:235] http service listen on 0.0.0.0:9098 2021/07/06 15:14:07 [I] [root.go:209] frps started successfully
2. 启动客户端,在fprc目录下面执行
```go
go run *.go -c frpc.ini
2021/07/06 15:15:40 [I] [service.go:304] [6af11efc2f567073] login to server success, get run id [6af11efc2f567073], server udp port [0]
2021/07/06 15:15:40 [I] [proxy_manager.go:144] [6af11efc2f567073] proxy added: [web01]
2021/07/06 15:15:40 [I] [control.go:180] [6af11efc2f567073] [web01] start proxy success
- 成功访问 127.0.0.1:9098/ (该127.0.0.1 实际需要替换你的公网ip地址),通过9098端口转发到内网端口 8181
- 自己打包编译
服务端centos: GOOS=linux GOARCH=amd64 go build -o frps *.go 客户端: go build
第二种方式部署包,不依赖本地环境
- 复制 上面所说的 frps.ini 和 frpc.ini 放置当前软件同级目录
- 下载windows, mac 和 linux 部署包,linux部署包需要部署到自己的服务器 , 客户端包需要本地运行,部署包下载地址
- 启动服务端 ./frps -c frps.ini
- 本地启动客户端 ./frpc -c frpc.ini
本作品采用《CC 协议》,转载必须注明作者和本文链接
缺的是服务器啊