需求
- 本机站点支持外网访问,方便快速调试
必须条件
- 一台公网服务器
- 域名
准备工作
-
frp软件源码地址
//源码包 https://github.com/fatedier/frp/ //安装包 https://github.com/fatedier/frp/releases
frp服务端安装配置(服务器)
- 修改 frps.ini
[common] # frp监听的端口,用作服务端和客户端通信 bind_port = 7000 # 监听 HTTP 请求 vhost_http_port = 7001 # frp 提供的管理端 仪表盘 dashboard_port = 7500 #管理面板账号 dashboard_user = admin #管理面板密码 dashboard_pwd = admin
- 启动frps.exe
frps.exe -c frps.ini
- 查看
frp
进程ps -aux | grep frp
- 添加开机启动frp服务端
frp客户端安装配置(本机)
- 修改 客户端 frpc.ini
[common] server_addr = www.xxx.com server_port = 7000 #web网站A [http-test] type = http #本地ip local_ip = 127.0.0.1 # 内网端口 local_port = 1050 #暴露外网端口 remote_port = 80 #绑定域名 custom_domains = a.xxx.com #web网站B [http-test2] type = http #本地ip local_ip = 127.0.0.1 #内网端口 local_port = 1040 #暴露外网端口 remote_port = 80 #绑定域名 custom_domains = b.xxx.com #sql数据库 [sql_tcp_1433] type = tcp local_ip = 127.0.0.1 #内网端口 local_port = 1433 #暴露外网端口 remote_port = 1433 #数据库连接使用地址 custom_domains = sql.xxx.com
- 启动客户端 frpc.exe
frpc.exe -c frpc.ini pause #重启客户端 #frpc -c ./frpc.ini --reload
效果
打开访问地址:http://www.xxx.com:7500