通用中转服务器配置
bindPort = 7000 # 用于转发消息,并非实际业务端口
auth.method = "token" # token验证,保护frp在转发目标和中继服务器的安全
auth.tokenSource.type = "file" # 文件方式存token,更安全
auth.tokenSource.file.path = "/path/to/token" # 存储token的文件路径,简单的文本文件(不需要扩展名),token为自定义字符串通用服务客户端配置
serverAddr = "remote_ip" # 中继服务器IP
serverPort = port_number # 中继服务器端口,和上面bindPort一样
auth.method = "token"
auth.tokenSource.type = "file"
auth.tokenSource.file.path = "/path/to/token"
[[proxies]]
name = "smb" # 随便起名
type = "tcp"
localIP = "127.0.0.1"
localPort = 445
remotePort = 11450 # 你希望在中继服务器的哪个端口进行转发。frp会在中继服务器上占用此端口
[[proxies]]
name = "ssh"
type = "tcp"
localIP = "127.0.0.1"
localPort = 22
remotePort = 11451Nginx Proxy Manager协作中转服务器配置
bindPort = 7000
vhostHTTPPort = 80
auth.method = "token"
auth.tokenSource.type = "file"
auth.tokenSource.file.path = "/etc/frp/token"注:
- 仅开放http vhost
Nginx Proxy Manager协作服务客户端配置
serverAddr = "158.247.241.178"
serverPort = 7000
auth.method = "token"
auth.tokenSource.type = "file"
auth.tokenSource.file.path = "/etc/frp/token"
[[proxies]]
name = "http-proxy"
type = "http"
localIP = "192.168.31.187"
localPort = 80
customDomains = ["syner.top","*.syner.top"]
[[proxies]]
name = "https-proxy"
type = "tcp"
localIP = "192.168.31.187"
localPort = 443
remotePort = 443注:
- 服务器接管所有来自服务器80的流量(syner.top及所有子域名),并用http方式转发给本机
- 服务器接管所有来自服务器443的流量,并用tcp方式转发给本机(即用原始数据方式将https内容转发到本机由NPM处理。否则会被FRP接管。正确方式是交给NPM接管,解析https内容,从而实现ssl访问)
常见问题
FRP 客户端http代理配置问题排查
问题概述
frpc 服务(frpc_coffee.service)在启动时反复失败,错误日志提示 unmarshal ProxyConfig error: json: unknown field "remotePort"。
错误原因
- 配置文件字段错误:
frpc客户端配置文件coffee.toml中,[[proxies]]的type字段被设置为http,但同时使用了remotePort字段。 - 配置格式不兼容:
frp的新版配置文件(TOML 格式)中,http类型代理不再使用remotePort字段,该字段仅适用于tcp和udp类型代理。
解决步骤
- 修改客户端配置文件: 将 coffee.toml 文件中的 remotePort = 80 这行删除。 根据实际需求,使用 customDomains 或 subdomain 字段来指定代理的域名或子域名。 示例 (使用子域名)
serverAddr = "158.247.241.178"
serverPort = 7000
[[proxies]]
name = "coyacoffee"
type = "http"
localIP = "127.0.0.1"
localPort = 11450
subdomain = "coyacoffee"- frpc 客户端新问题: 在修改并重启服务后,frpc 客户端依然启动失败,错误信息为 start error: type [http] not supported when vhost http port is not set。
解决步骤
- 问题原因: 这个错误表明 frps 服务器端的配置文件没有启用 HTTP 服务的虚拟主机端口。当客户端请求 http 代理时,服务器端没有对应的端口来接收请求。
- 修改服务器端配置: 登录到 frps 服务器,编辑其配置文件(通常为 frps.toml),添加或修改 vhostHTTPPort 字段。
bindPort = 7000
vhostHTTPPort = 80 # 添加或修改此行bindPort是客户端与服务器通信的端口。vhostHTTPPort是处理 HTTP 代理请求的端口。
- 重启 frps 服务器服务: 保存配置文件后,重启 frps 服务以应用更改。
sudo systemctl restart frps.service