[GH-ISSUE #4469] [Feature Request] 如何设置frp让他能够代理在一台内网电脑中的多个http服务 #3532

Closed
opened 2026-05-05 14:16:14 -06:00 by gitea-mirror · 7 comments
Owner

Originally created by @ddyykk on GitHub (Oct 4, 2024).
Original GitHub issue: https://github.com/fatedier/frp/issues/4469

Describe the feature request

我知道可以用子域名的方式来解决, 但这样稍微有些麻烦, 如果能用IP地址就可以少一笔域名的费用了.

我看以前 ini 配置文件时, http代理可以设置多个, 每个使用不同的localPort和remotePort, 现在似乎不能这样做了, 在http代理中设置remotePort参数程序就会报错无法启动.
以下是我的代码实例:
frps.toml:

bindPort = 7000
vhostHTTPPort = 8080
# This is the port to use when client try to access the service


auth.method = "token"
auth.token = "xxxxxxx"

frpc.toml:

serverAddr = "x.x.x.x"
serverPort = 7000
auth.method = "token"
auth.token = "xxxxxxx"

[[proxies]]
name = "web1"
type = "http"
localIP = "192.168.3.131"
localPort = 8081
customDomains = ["serverAddr"]

[[proxies]]
name = "ssh"
type = "tcp"
localIP = "192.168.3.131"
localPort = 22
remotePort = 6002

如何能增加多个http proxy

[[proxies]]
name = "web2"
type = "http"
localIP = "192.168.3.131"
localPort = 8082
customDomains = ["serverAddr"]

Describe alternatives you've considered

No response

Affected area

  • Docs
  • Installation
  • Performance and Scalability
  • Security
  • User Experience
  • Test and Release
  • Developer Infrastructure
  • Client Plugin
  • Server Plugin
  • Extensions
  • Others
Originally created by @ddyykk on GitHub (Oct 4, 2024). Original GitHub issue: https://github.com/fatedier/frp/issues/4469 ### Describe the feature request 我知道可以用子域名的方式来解决, 但这样稍微有些麻烦, 如果能用IP地址就可以少一笔域名的费用了. 我看以前 ini 配置文件时, http代理可以设置多个, 每个使用不同的localPort和remotePort, 现在似乎不能这样做了, 在http代理中设置remotePort参数程序就会报错无法启动. 以下是我的代码实例: frps.toml: ```bash bindPort = 7000 vhostHTTPPort = 8080 # This is the port to use when client try to access the service auth.method = "token" auth.token = "xxxxxxx" ``` frpc.toml: ```bash serverAddr = "x.x.x.x" serverPort = 7000 auth.method = "token" auth.token = "xxxxxxx" [[proxies]] name = "web1" type = "http" localIP = "192.168.3.131" localPort = 8081 customDomains = ["serverAddr"] [[proxies]] name = "ssh" type = "tcp" localIP = "192.168.3.131" localPort = 22 remotePort = 6002 ``` 如何能增加多个http proxy ```bash [[proxies]] name = "web2" type = "http" localIP = "192.168.3.131" localPort = 8082 customDomains = ["serverAddr"] ``` ### Describe alternatives you've considered _No response_ ### Affected area - [ ] Docs - [ ] Installation - [ ] Performance and Scalability - [ ] Security - [X] User Experience - [ ] Test and Release - [ ] Developer Infrastructure - [ ] Client Plugin - [ ] Server Plugin - [ ] Extensions - [ ] Others
Author
Owner

@superzjg commented on GitHub (Oct 5, 2024):

试试 type = "tcp"

<!-- gh-comment-id:2394850907 --> @superzjg commented on GitHub (Oct 5, 2024): 试试 `type = "tcp"`
Author
Owner

@ddyykk commented on GitHub (Oct 5, 2024):

在frpc.toml加入这一段:

[[proxies]]
name = "service2"
type = "tcp"
localIP = "192.168.3.131"
localPort = 8897
remotePort = 8897
customDomains = ["193.x.xx.x"]

然后还是启动不成功, 日志中的错误是:
frpc[27243]: unmarshal ProxyConfig error: json: unknown field "remotePort"

似乎remotePort参数只能有一个, 或者tcp proxy只能有一个, ssh 有了就不能再有.

<!-- gh-comment-id:2394860503 --> @ddyykk commented on GitHub (Oct 5, 2024): 在frpc.toml加入这一段: ```bash [[proxies]] name = "service2" type = "tcp" localIP = "192.168.3.131" localPort = 8897 remotePort = 8897 customDomains = ["193.x.xx.x"] ``` 然后还是启动不成功, 日志中的错误是: ` frpc[27243]: unmarshal ProxyConfig error: json: unknown field "remotePort"` 似乎remotePort参数只能有一个, 或者tcp proxy只能有一个, ssh 有了就不能再有.
Author
Owner

@superzjg commented on GitHub (Oct 5, 2024):

在frpc.toml加入这一段:

[[proxies]]
name = "service2"
type = "tcp"
localIP = "192.168.3.131"
localPort = 8897
remotePort = 8897
customDomains = ["193.x.xx.x"]

然后还是启动不成功, 日志中的错误是: frpc[27243]: unmarshal ProxyConfig error: json: unknown field "remotePort"

似乎remotePort参数只能有一个, 或者tcp proxy只能有一个, ssh 有了就不能再有.

tcp 与 remotePort 相配,与 customDomains 不相容,删除。
直接使用 frps 所在服务器的其中一个域名即可,配上端口号使用。

<!-- gh-comment-id:2394907846 --> @superzjg commented on GitHub (Oct 5, 2024): > 在frpc.toml加入这一段: > > ```shell > [[proxies]] > name = "service2" > type = "tcp" > localIP = "192.168.3.131" > localPort = 8897 > remotePort = 8897 > customDomains = ["193.x.xx.x"] > ``` > > 然后还是启动不成功, 日志中的错误是: ` frpc[27243]: unmarshal ProxyConfig error: json: unknown field "remotePort"` > > 似乎remotePort参数只能有一个, 或者tcp proxy只能有一个, ssh 有了就不能再有. tcp 与 remotePort 相配,与 customDomains 不相容,删除。 直接使用 frps 所在服务器的其中一个域名即可,配上端口号使用。
Author
Owner

@ddyykk commented on GitHub (Oct 5, 2024):

可以了, 多谢

<!-- gh-comment-id:2394916915 --> @ddyykk commented on GitHub (Oct 5, 2024): 可以了, 多谢
Author
Owner

@liu1015 commented on GitHub (Oct 8, 2024):

可以了, 多谢

您好,可以看看你的配置吗?我也是没办法实现多个http配置

<!-- gh-comment-id:2398455100 --> @liu1015 commented on GitHub (Oct 8, 2024): > 可以了, 多谢 您好,可以看看你的配置吗?我也是没办法实现多个http配置
Author
Owner

@ddyykk commented on GitHub (Oct 8, 2024):

serverAddr = "x.x.x.x"
serverPort = 7000
auth.method = "token"
auth.token = "xxxxxxx"

[[proxies]]
name = "web1"
type = "http"
localIP = "192.168.3.131"
localPort = 8081

[[proxies]]
name = "web2"
type = "tcp"
localIP = "192.168.3.131"
localPort = 8080
remotePort = 8080

[[proxies]]
name = "web3"
type = "tcp"
localIP = "192.168.3.131"
localPort = 8082
remotePort = 8085

要在frps部署的vps上的防火墙打开remote端口就可以

<!-- gh-comment-id:2398465531 --> @ddyykk commented on GitHub (Oct 8, 2024): ```toml serverAddr = "x.x.x.x" serverPort = 7000 auth.method = "token" auth.token = "xxxxxxx" [[proxies]] name = "web1" type = "http" localIP = "192.168.3.131" localPort = 8081 [[proxies]] name = "web2" type = "tcp" localIP = "192.168.3.131" localPort = 8080 remotePort = 8080 [[proxies]] name = "web3" type = "tcp" localIP = "192.168.3.131" localPort = 8082 remotePort = 8085 ``` 要在frps部署的vps上的防火墙打开remote端口就可以
Author
Owner

@wahahaer commented on GitHub (Dec 10, 2024):

试试 type = "tcp"

在没办法使用多个端口来映射不同的http服务时,没办法将类型改为了tcp
但是返回的结果,偶尔会报错:
curl: (1) Received HTTP/0.9 when not allowed

2024/12/10 18:44:41 [error] 9226#9226: *14 upstream sent no valid HTTP/1.0 header while reading response header from upstream, client: 39.101.xx.xx, server: 39.101.xx.xx, request: "POST /v1/chat/completions HTTP/1.1", upstream: "http://39.101.xx.xx:9010/v1/chat/completions", host: "39.101.xx.xx"

<!-- gh-comment-id:2531256598 --> @wahahaer commented on GitHub (Dec 10, 2024): > 试试 `type = "tcp"` 在没办法使用多个端口来映射不同的http服务时,没办法将类型改为了tcp 但是返回的结果,偶尔会报错: curl: (1) Received HTTP/0.9 when not allowed 2024/12/10 18:44:41 [error] 9226#9226: *14 upstream sent no valid HTTP/1.0 header while reading response header from upstream, client: 39.101.xx.xx, server: 39.101.xx.xx, request: "POST /v1/chat/completions HTTP/1.1", upstream: "http://39.101.xx.xx:9010/v1/chat/completions", host: "39.101.xx.xx"
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/frp#3532
No description provided.