[GH-ISSUE #5197] [Feature Request] frpc 支持通过单个实例连接多个远程服务器 (Multiple server connections in one frpc instance) #4058

Closed
opened 2026-05-05 14:34:17 -06:00 by gitea-mirror · 5 comments
Owner

Originally created by @lc6464 on GitHub (Mar 5, 2026).
Original GitHub issue: https://github.com/fatedier/frp/issues/5197

Describe the feature request

期望

希望 frpc 能够支持在单个进程中管理多个服务器连接。
简单的实现方案:

  1. 多个 -c 参数导入多个配置文件
  2. 单个 -c 参数导入配置文件夹
  3. 在单个配置文件内区分不同的 server 和对应的 proxy、visitor 等(可能具有破坏性)

现状

目前 frpc 的架构设计为一个进程对应一个远程服务器 frps,当需要连接到多个服务器建立不同的代理时,必须在后台维护多个 frpc 进程。

这带来了一些运维上的不便:

  • 进程管理复杂: 需要维护多个 systemd 服务单元、nssm 服务管理器或其它守护进程。
  • 资源占用: 虽然 frp 很轻量,但多个进程依然比单进程多占用了一些系统资源。
  • 日志分散: 不同实例的日志打印在不同的地方,不利于统一监控。

Describe alternatives you've considered

也可以实现一个 frp 进程管理器,用于统一拉起和管理多个 frp 子进程

Affected area

  • Docs
  • Installation
  • Performance and Scalability
  • Security
  • User Experience
  • Test and Release
  • Developer Infrastructure
  • Client Plugin
  • Server Plugin
  • Extensions
  • Others
Originally created by @lc6464 on GitHub (Mar 5, 2026). Original GitHub issue: https://github.com/fatedier/frp/issues/5197 ### Describe the feature request #### 期望 希望 frpc 能够支持在单个进程中管理多个服务器连接。 简单的实现方案: 1. 多个 `-c` 参数导入多个配置文件 2. 单个 `-c` 参数导入配置文件夹 3. 在单个配置文件内区分不同的 server 和对应的 proxy、visitor 等(可能具有破坏性) #### 现状 目前 frpc 的架构设计为一个进程对应一个远程服务器 frps,当需要连接到多个服务器建立不同的代理时,必须在后台维护多个 frpc 进程。 这带来了一些运维上的不便: - 进程管理复杂: 需要维护多个 systemd 服务单元、nssm 服务管理器或其它守护进程。 - 资源占用: 虽然 frp 很轻量,但多个进程依然比单进程多占用了一些系统资源。 - 日志分散: 不同实例的日志打印在不同的地方,不利于统一监控。 ### Describe alternatives you've considered 也可以实现一个 frp 进程管理器,用于统一拉起和管理多个 frp 子进程 ### Affected area - [ ] Docs - [ ] Installation - [x] Performance and Scalability - [ ] Security - [ ] User Experience - [ ] Test and Release - [ ] Developer Infrastructure - [ ] Client Plugin - [ ] Server Plugin - [ ] Extensions - [ ] Others
gitea-mirror 2026-05-05 14:34:17 -06:00
Author
Owner

@github-actions[bot] commented on GitHub (Mar 20, 2026):

Issues go stale after 14d of inactivity. Stale issues rot after an additional 3d of inactivity and eventually close.

<!-- gh-comment-id:4094655162 --> @github-actions[bot] commented on GitHub (Mar 20, 2026): Issues go stale after 14d of inactivity. Stale issues rot after an additional 3d of inactivity and eventually close.
Author
Owner

@lc6464 commented on GitHub (Mar 20, 2026):

Hello?

<!-- gh-comment-id:4094685822 --> @lc6464 commented on GitHub (Mar 20, 2026): Hello?
Author
Owner

@litrycn commented on GitHub (Mar 24, 2026):

./frpc -h
...
Flags:
  -c, --config string       config file of frpc (default "./frpc.ini")
      --config-dir string   config directory, run one frpc service for each file in config directory
  -h, --help                help for frpc
      --strict-config       strict config parsing mode, unknown fields will cause an errors (default true)
  -v, --version             version of frpc

Use "frpc [command] --help" for more information about a command.

在./dir 创建多个服务器的json配置

ll dir
total 20
-rw-r--r-- 1 root root 903 Mar 24 13:59 123456789.json
-rw-r--r-- 1 root root 898 Mar 24 13:59 12345678.json
-rw-r--r-- 1 root root 893 Mar 24 13:59 1234567.json
-rw-r--r-- 1 root root 888 Mar 24 13:59 123456.json
-rw-r--r-- 1 root root 883 Mar 24 13:59 12345.json

执行 ./frpc --config-dir ./dir

./frpc --config-dir ./dir
2026-03-24 14:01:15.482 [I] [sub/root.go:149] start frpc service for config file [dir/12345.json]
2026-03-24 14:01:15.486 [I] [sub/root.go:149] start frpc service for config file [dir/123456.json]
2026-03-24 14:01:15.487 [I] [sub/root.go:149] start frpc service for config file [dir/1234567.json]
2026-03-24 14:01:15.488 [I] [sub/root.go:159] frpc service for config file [dir/12345.json] stopped
frpc service error for config file [dir/12345.json]
2026-03-24 14:01:15.490 [I] [sub/root.go:149] start frpc service for config file [dir/123456789.json]
2026-03-24 14:01:15.491 [I] [client/service.go:325] try to connect to server...
2026-03-24 14:01:15.489 [I] [sub/root.go:149] start frpc service for config file [dir/12345678.json]
2026-03-24 14:01:15.491 [I] [client/service.go:204] admin server listen on 127.0.0.1:13109
2026-03-24 14:01:15.490 [I] [client/service.go:204] admin server listen on 127.0.0.1:13107
2026-03-24 14:01:15.493 [I] [client/service.go:325] try to connect to server...
2026-03-24 14:01:15.493 [I] [client/service.go:204] admin server listen on 127.0.0.1:13108
2026-03-24 14:01:15.489 [I] [client/service.go:325] try to connect to server...
2026-03-24 14:01:15.489 [I] [client/service.go:204] admin server listen on 127.0.0.1:13106
2026-03-24 14:01:15.489 [I] [client/service.go:325] try to connect to server...

唯一的问题是 其中一个 服务因为网络问题没连上 就连不上了,frpc绑定的端口好像没释放(没有细测)

<!-- gh-comment-id:4115644854 --> @litrycn commented on GitHub (Mar 24, 2026): ``` ./frpc -h ... Flags: -c, --config string config file of frpc (default "./frpc.ini") --config-dir string config directory, run one frpc service for each file in config directory -h, --help help for frpc --strict-config strict config parsing mode, unknown fields will cause an errors (default true) -v, --version version of frpc Use "frpc [command] --help" for more information about a command. ``` 在./dir 创建多个服务器的json配置 ``` ll dir total 20 -rw-r--r-- 1 root root 903 Mar 24 13:59 123456789.json -rw-r--r-- 1 root root 898 Mar 24 13:59 12345678.json -rw-r--r-- 1 root root 893 Mar 24 13:59 1234567.json -rw-r--r-- 1 root root 888 Mar 24 13:59 123456.json -rw-r--r-- 1 root root 883 Mar 24 13:59 12345.json ``` 执行 ./frpc --config-dir ./dir ``` ./frpc --config-dir ./dir 2026-03-24 14:01:15.482 [I] [sub/root.go:149] start frpc service for config file [dir/12345.json] 2026-03-24 14:01:15.486 [I] [sub/root.go:149] start frpc service for config file [dir/123456.json] 2026-03-24 14:01:15.487 [I] [sub/root.go:149] start frpc service for config file [dir/1234567.json] 2026-03-24 14:01:15.488 [I] [sub/root.go:159] frpc service for config file [dir/12345.json] stopped frpc service error for config file [dir/12345.json] 2026-03-24 14:01:15.490 [I] [sub/root.go:149] start frpc service for config file [dir/123456789.json] 2026-03-24 14:01:15.491 [I] [client/service.go:325] try to connect to server... 2026-03-24 14:01:15.489 [I] [sub/root.go:149] start frpc service for config file [dir/12345678.json] 2026-03-24 14:01:15.491 [I] [client/service.go:204] admin server listen on 127.0.0.1:13109 2026-03-24 14:01:15.490 [I] [client/service.go:204] admin server listen on 127.0.0.1:13107 2026-03-24 14:01:15.493 [I] [client/service.go:325] try to connect to server... 2026-03-24 14:01:15.493 [I] [client/service.go:204] admin server listen on 127.0.0.1:13108 2026-03-24 14:01:15.489 [I] [client/service.go:325] try to connect to server... 2026-03-24 14:01:15.489 [I] [client/service.go:204] admin server listen on 127.0.0.1:13106 2026-03-24 14:01:15.489 [I] [client/service.go:325] try to connect to server... ``` 唯一的问题是 其中一个 服务因为网络问题没连上 就连不上了,frpc绑定的端口好像没释放(没有细测)
Author
Owner

@github-actions[bot] commented on GitHub (Apr 8, 2026):

Issues go stale after 14d of inactivity. Stale issues rot after an additional 3d of inactivity and eventually close.

<!-- gh-comment-id:4203125708 --> @github-actions[bot] commented on GitHub (Apr 8, 2026): Issues go stale after 14d of inactivity. Stale issues rot after an additional 3d of inactivity and eventually close.
Author
Owner

@lc6464 commented on GitHub (Apr 12, 2026):

./frpc -h
...
Flags:
  -c, --config string       config file of frpc (default "./frpc.ini")
      --config-dir string   config directory, run one frpc service for each file in config directory
  -h, --help                help for frpc
      --strict-config       strict config parsing mode, unknown fields will cause an errors (default true)
  -v, --version             version of frpc

Use "frpc [command] --help" for more information about a command.

在./dir 创建多个服务器的json配置

ll dir
total 20
-rw-r--r-- 1 root root 903 Mar 24 13:59 123456789.json
-rw-r--r-- 1 root root 898 Mar 24 13:59 12345678.json
-rw-r--r-- 1 root root 893 Mar 24 13:59 1234567.json
-rw-r--r-- 1 root root 888 Mar 24 13:59 123456.json
-rw-r--r-- 1 root root 883 Mar 24 13:59 12345.json

执行 ./frpc --config-dir ./dir

./frpc --config-dir ./dir
2026-03-24 14:01:15.482 [I] [sub/root.go:149] start frpc service for config file [dir/12345.json]
2026-03-24 14:01:15.486 [I] [sub/root.go:149] start frpc service for config file [dir/123456.json]
2026-03-24 14:01:15.487 [I] [sub/root.go:149] start frpc service for config file [dir/1234567.json]
2026-03-24 14:01:15.488 [I] [sub/root.go:159] frpc service for config file [dir/12345.json] stopped
frpc service error for config file [dir/12345.json]
2026-03-24 14:01:15.490 [I] [sub/root.go:149] start frpc service for config file [dir/123456789.json]
2026-03-24 14:01:15.491 [I] [client/service.go:325] try to connect to server...
2026-03-24 14:01:15.489 [I] [sub/root.go:149] start frpc service for config file [dir/12345678.json]
2026-03-24 14:01:15.491 [I] [client/service.go:204] admin server listen on 127.0.0.1:13109
2026-03-24 14:01:15.490 [I] [client/service.go:204] admin server listen on 127.0.0.1:13107
2026-03-24 14:01:15.493 [I] [client/service.go:325] try to connect to server...
2026-03-24 14:01:15.493 [I] [client/service.go:204] admin server listen on 127.0.0.1:13108
2026-03-24 14:01:15.489 [I] [client/service.go:325] try to connect to server...
2026-03-24 14:01:15.489 [I] [client/service.go:204] admin server listen on 127.0.0.1:13106
2026-03-24 14:01:15.489 [I] [client/service.go:325] try to connect to server...

唯一的问题是 其中一个 服务因为网络问题没连上 就连不上了,frpc绑定的端口好像没释放(没有细测)

是我草率了,没仔细看 --help

<!-- gh-comment-id:4230814862 --> @lc6464 commented on GitHub (Apr 12, 2026): > ``` > ./frpc -h > ... > Flags: > -c, --config string config file of frpc (default "./frpc.ini") > --config-dir string config directory, run one frpc service for each file in config directory > -h, --help help for frpc > --strict-config strict config parsing mode, unknown fields will cause an errors (default true) > -v, --version version of frpc > > Use "frpc [command] --help" for more information about a command. > ``` > > 在./dir 创建多个服务器的json配置 > > ``` > ll dir > total 20 > -rw-r--r-- 1 root root 903 Mar 24 13:59 123456789.json > -rw-r--r-- 1 root root 898 Mar 24 13:59 12345678.json > -rw-r--r-- 1 root root 893 Mar 24 13:59 1234567.json > -rw-r--r-- 1 root root 888 Mar 24 13:59 123456.json > -rw-r--r-- 1 root root 883 Mar 24 13:59 12345.json > ``` > > 执行 ./frpc --config-dir ./dir > > ``` > ./frpc --config-dir ./dir > 2026-03-24 14:01:15.482 [I] [sub/root.go:149] start frpc service for config file [dir/12345.json] > 2026-03-24 14:01:15.486 [I] [sub/root.go:149] start frpc service for config file [dir/123456.json] > 2026-03-24 14:01:15.487 [I] [sub/root.go:149] start frpc service for config file [dir/1234567.json] > 2026-03-24 14:01:15.488 [I] [sub/root.go:159] frpc service for config file [dir/12345.json] stopped > frpc service error for config file [dir/12345.json] > 2026-03-24 14:01:15.490 [I] [sub/root.go:149] start frpc service for config file [dir/123456789.json] > 2026-03-24 14:01:15.491 [I] [client/service.go:325] try to connect to server... > 2026-03-24 14:01:15.489 [I] [sub/root.go:149] start frpc service for config file [dir/12345678.json] > 2026-03-24 14:01:15.491 [I] [client/service.go:204] admin server listen on 127.0.0.1:13109 > 2026-03-24 14:01:15.490 [I] [client/service.go:204] admin server listen on 127.0.0.1:13107 > 2026-03-24 14:01:15.493 [I] [client/service.go:325] try to connect to server... > 2026-03-24 14:01:15.493 [I] [client/service.go:204] admin server listen on 127.0.0.1:13108 > 2026-03-24 14:01:15.489 [I] [client/service.go:325] try to connect to server... > 2026-03-24 14:01:15.489 [I] [client/service.go:204] admin server listen on 127.0.0.1:13106 > 2026-03-24 14:01:15.489 [I] [client/service.go:325] try to connect to server... > ``` > > 唯一的问题是 其中一个 服务因为网络问题没连上 就连不上了,frpc绑定的端口好像没释放(没有细测) 是我草率了,没仔细看 --help
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#4058
No description provided.