frp简介

FRP 项目地址 https://github.com/fatedier/frp/blob/master/README_zh.md

frp 是一个专注于内网穿透的高性能的反向代理应用,支持 TCP、UDP、HTTP、HTTPS 等多种协议。可以将内网服务以安全、便捷的方式通过具有公网 IP 节点的中转暴露到公网。

为什么使用frp

通过在具有公网 IP 的节点上部署 frp 服务端,可以轻松地将内网服务穿透到公网,同时提供诸多专业的功能特性,这包括:

  • 客户端服务端通信支持 TCP、KCP 以及 Websocket 等多种协议。
  • 采用 TCP 连接流式复用,在单个连接间承载更多请求,节省连接建立时间。
  • 代理组间的负载均衡。
  • 端口复用,多个服务通过同一个服务端端口暴露。
  • 多个原生支持的客户端插件(静态文件查看,HTTP、SOCK5 代理等),便于独立使用 frp 客户端完成某些工作。
  • 高度扩展性的服务端插件系统,方便结合自身需求进行功能扩展。
  • 服务端和客户端 UI 页面。

文档及示例

官方文档及示例

Server端

搭建

cd /data
wget https://ghproxy.com/https://github.com/fatedier/frp/releases/download/v0.37.1/frp_0.37.1_linux_amd64.tar.gz
tar -xzvf frp_0.37.1_linux_amd64.tar.gz 
mv frp_0.37.1_linux_amd64 frps
cd frps 
# 后台启动
nohup ./frps -c ./frps.ini &

配置文件

[common]
# 服务端监听端口
bind_port = 7901

# HTTPS 类型代理监听的端口
vhost_https_port = 7902
# HTTP 类型代理监听的端口
vhost_http_port = 7903

# token鉴权
authentication_method = token
token = xxxx

# Dashboard 监听的本地端口
dashboard_port = 7900
# HTTP BasicAuth 用户名
dashboard_user = xxx
# HTTP BasicAuth 密码
dashboard_pwd = xxx

client端

这里举了一些常见的例子

配置文件

[common]
server_addr = xxx.xxx.xxx.xxx
server_port = 7901
authentication_method = token
token = xxxx

# http
# 访问: http://sub1.xxx.cn:7903
[web-lab]
type = http
local_ip = 127.0.0.1
local_port = 8080
custom_domains = sub1.xxx.cn

# https
# 访问: https://sub2.xx.cn:7902
[web-jpgk]
type = https
custom_domains = sub2.xx.cn
plugin = https2http
plugin_local_addr = 127.0.0.1:8780
# HTTPS 证书相关的配置
plugin_crt_path = ./xxx/crt.crt
plugin_key_path = ./xxx/key.key
plugin_host_header_rewrite = 127.0.0.1
plugin_header_X-From-Where = frp

# tcp mysql
[mysql]
type = tcp
local_ip = 127.0.0.1
local_port = 3306
remote_port = 13306

# tcp win远程桌面
[rd]
type = tcp
local_ip = 127.0.0.1
local_port = 3389
remote_port = 13389

测试

8Mbps带宽测试下载

8Mbps带宽测试下载

远程桌面

test-frp-rd-1

test-frp-rd-2