介绍
- frp 是一个可用于内网穿透的高性能的反向代理应用,支持 tcp, udp, http, https 协议
- 分为服务端和客户端
- 所以服务端和客户端都需要配置
前提
- 需要有一台公网服务器
- 需要有一个可用的域名,假设为:yourdomain.com
域名解析配置
- 在万网或其他网站配置解析
- 配置为 * ,表示二级域名 test.yourdomain.com ,test2.yourdomain.com 等都能解析到对应的公网服务器ip

下载对应的安装包
https://github.com/fatedier/frp/releases
假设公网服务器为linux,内网为windows

配置公网服务器(服务端)
- 把下载的frp_0.13.0_linux_amd64.tar.gz上传到公网服务器
- 解压
- 修改 frps.ini
[common]
bind_port = 7000
vhost_http_port = 8080
subdomain_host = yourdomain.com
dashboard_port = 7500
dashboard_user = admin
dashboard_pwd = admin
./frps -c ./frps.ini
配置客户端
- 解压 frp_0.13.0_windows_amd64.zip
- 修改 frpc.ini
[common]
server_addr = x.x.x.x
server_port = 7000
[test]
type = http
local_port = 9999
subdomain = test
frpc.exe -c frpc.ini
浏览器访问
http://test.yourdomain.com:8080 # 就能访问到内网的 web server
http://test.yourdomain.com:7500 # 就能访问dashboard
注意
- 公网服务器(服务端)的防火墙不要忘了开放对应的端口,比如上面的:7000 ,7500,8080
- 如果是阿里云服务器,还需要在管理控制台添加安全组规则,允许访问:7000 ,7500,8080
- 更多配置请参考官方文档
参考资料
- https://github.com/fatedier/frp