新版本内网穿透工具frp,搭建保姆级教程
新版本更新了不少配置,感兴趣的可以去官方文档研究研究
下载安装包,请点击历史文章 本文不再啰嗦
历史版本参考
安装 systemd
如果您的 Linux 服务器上尚未安装 systemd,可以使用包管理器如 yum(适用于 CentOS/RHEL)或 apt(适用于 Debian/Ubuntu)来安装它:
使用 yum 安装 systemd(CentOS/RHEL)
yum install systemd
使用 apt 安装 systemd(Debian/Ubuntu)
apt install systemd
创建 frps.service 文件
使用文本编辑器 (如 vim) 在 /etc/systemd/system 目录下创建一个 frps.service 文件,用于配置 frps 服务。
$ sudo vim /etc/systemd/system/frps.service
写入内容
[Unit]
# 服务名称,可自定义
Description = frp server
After = network.target syslog.target
Wants = network.target
[Service]
Type = simple
# 启动frps的命令,需修改为您的frps的安装路径
ExecStart = /path/to/frps -c /path/to/frps.toml
[Install]
WantedBy = multi-user.target
启动frps的命令,需修改为您的frps的安装路径
ExecStart = /path/to/frps -c /path/to/frps.toml
[Install]
WantedBy = multi-user.target
使用 systemd 命令管理 frps 服务
启动frp
sudo systemctl start frps
停止frp
sudo systemctl stop frps
重启frp
sudo systemctl restart frps
查看frp状态
sudo systemctl status frps
设置 frps 开机自启动
sudo systemctl enable frps
frps.toml参考配置
#绑定端口
bindPort = 7000
# 如果指定了“oidc”,将使用 OIDC 设置颁发 OIDC(开放 ID 连接)令牌。默认情况下,此值为“令牌”。auth.method = “token”
auth.method = "token"
# 身份验证令牌 auth.token = “12345678”
auth.token = "12345678"
# 配置 Web 服务器以启用 frps 的仪表板。
webServer.addr = "0.0.0.0"
webServer.port = 7500
webServer.user = "admin"
webServer.password = "xxxxx"
##特别说明---如果客户端要配置type为http类型代理时,需要配置以下虚拟机端口
# 虚拟主机端口
vhostHTTPPort = 8080
## SSL 虚拟主机端口
vhostHTTPSPort = 1443
# 日志配置
log.to = "/path/to/frps.log"
log.level = "info"
log.maxDays = 3
# disable log colors when log.to is console, default is false
log.disablePrintColor = false
客户端搭建步骤
下载安装frps对应客户端版本,具体可参考下老版本
更改frpc.toml文件
# 修改为frps部署服务器ip
serverAddr = "x.x.x.x"
#frps部署服务器端口
serverPort = 7000
#鉴权方式,可选值为 token 或 oidc,默认为 token。
auth.method = "token"
# 身份验证令牌
auth.token = "12345678"
# 设置管理员地址,通过 http API 控制 frpc 的操作,例如重新加载
webServer.addr = "0.0.0.0"
webServer.port = 7400
webServer.user = "admin"
webServer.password = "123456"
webServer.pprofEnable = false
# 日志配置
log.to = "/path/to/frpc.log"
log.level = "info"
log.maxDays = 3
# disable log colors when log.to is console, default is false
log.disablePrintColor = false
[[proxies]]
name = "tcp01"
type = "tcp"
localIP = "127.0.0.1"
localPort = 82
#如果remotePort为0,frps将为您分配一个随机端口
remotePort = 9000
[[proxies]]
name = "tcp02"
type = "tcp"
localPort = 83
remotePort = 9001
[[proxies]]
name = "http_web"
type = "http"
localPort = 83
remotePort = 9001
#配置服务器域名或ip
customDomains = ["xxx.xxx.xxx.xxx"]