[GH-ISSUE #3109] [Feature Request] FRPC建立的反代连接里面,可以指定端口 #2491

Closed
opened 2026-05-05 13:36:10 -06:00 by gitea-mirror · 12 comments
Owner

Originally created by @Wai5888 on GitHub (Sep 27, 2022).
Original GitHub issue: https://github.com/fatedier/frp/issues/3109

Describe the feature request

我的组网:

my_server---frpc---frps---dst_server

我的server需要明确对端的端口,并在一直的地址、端口信息下进行通信。

现有的情况:
dst_server通过frps的代理端口可以将数据转发给frpc,frpc可以再发送数据到my_server,但是my_server校验它的端口并非协商的端口,导致无法响应。

希望frpc的配置能增加一项配置,可以使得frpc可以绑定端口,并使用此端口往my_server发送数据。

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 @Wai5888 on GitHub (Sep 27, 2022). Original GitHub issue: https://github.com/fatedier/frp/issues/3109 ### Describe the feature request 我的组网: my_server---frpc---frps---dst_server 我的server需要明确对端的端口,并在一直的地址、端口信息下进行通信。 现有的情况: dst_server通过frps的代理端口可以将数据转发给frpc,frpc可以再发送数据到my_server,但是my_server校验它的端口并非协商的端口,导致无法响应。 希望frpc的配置能增加一项配置,可以使得frpc可以绑定端口,并使用此端口往my_server发送数据。 ### 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 - [X] Extensions - [ ] Others
gitea-mirror 2026-05-05 13:36:10 -06:00
Author
Owner

@Becods commented on GitHub (Sep 27, 2022):

# frpc.ini
[common]
server_addr = x.x.x.x
server_port = 7000

[ssh]
type = tcp
local_ip = 127.0.0.1
local_port = 22
remote_port = 6000
<!-- gh-comment-id:1259528740 --> @Becods commented on GitHub (Sep 27, 2022): <pre># frpc.ini [common] server_addr = x.x.x.x server_port = 7000 [ssh] type = tcp local_ip = 127.0.0.1 <b>local_port = 22</b> <b>remote_port = 6000</b></pre>
Author
Owner

@Wai5888 commented on GitHub (Sep 28, 2022):

frpc.ini

[common]
server_addr = x.x.x.x
server_port = 7000

[ssh]
type = tcp
local_ip = 127.0.0.1
local_port = 22
remote_port = 6000

可能我没有表达清楚,frpc的配置里面,local_port是用来监听并将数据传输给remote_port的,但是传给remote_port的时候,使用的端口并非是local_port。
它现在的实现是这样的:
frps-->frpc(local_port)
frpc(random_port)->my_server

而我希望,能够实现
frps-->frpc(local_port)
frpc(local_port2)->my_server

<!-- gh-comment-id:1260291635 --> @Wai5888 commented on GitHub (Sep 28, 2022): > # frpc.ini > [common] > server_addr = x.x.x.x > server_port = 7000 > > [ssh] > type = tcp > local_ip = 127.0.0.1 > local_port = 22 > remote_port = 6000 可能我没有表达清楚,frpc的配置里面,local_port是用来监听并将数据传输给remote_port的,但是传给remote_port的时候,使用的端口并非是local_port。 它现在的实现是这样的: frps-->frpc(local_port) frpc(random_port)->my_server 而我希望,能够实现 frps-->frpc(local_port) frpc(local_port2)->my_server
Author
Owner

@huanghe-1 commented on GitHub (Sep 28, 2022):

@Wai5888 你是要做p2p桥接呢吧,my-server和dst_server都是server,谁做client呢?两个server都在nat后面,没有公网ip?

<!-- gh-comment-id:1260348136 --> @huanghe-1 commented on GitHub (Sep 28, 2022): @Wai5888 你是要做p2p桥接呢吧,my-server和dst_server都是server,谁做client呢?两个server都在nat后面,没有公网ip?
Author
Owner

@Wai5888 commented on GitHub (Sep 28, 2022):

my_server和dst_server都是server,互为client,其实就类似P2P。只是FRP的P2P模式下,依旧会监听指定端口,使用随机端口去访问被代理的端口。这不是我想要的,因为my_server和dst_server都需要对数据从哪个端口发过来的做校验。

<!-- gh-comment-id:1260349782 --> @Wai5888 commented on GitHub (Sep 28, 2022): my_server和dst_server都是server,互为client,其实就类似P2P。只是FRP的P2P模式下,依旧会监听指定端口,使用随机端口去访问被代理的端口。这不是我想要的,因为my_server和dst_server都需要对数据从哪个端口发过来的做校验。
Author
Owner

@huanghe-1 commented on GitHub (Sep 28, 2022):

你这是桥接啊,实际上两端都是client,需要一个server 服务开两个端口,把两个client串起来,这种frp是实现不了的,你其实需要的是一个tcp client转tcp server,这样另一个tcp client就可以连接这个sever端口了。

<!-- gh-comment-id:1260411655 --> @huanghe-1 commented on GitHub (Sep 28, 2022): 你这是桥接啊,实际上两端都是client,需要一个server 服务开两个端口,把两个client串起来,这种frp是实现不了的,你其实需要的是一个tcp client转tcp server,这样另一个tcp client就可以连接这个sever端口了。
Author
Owner

@Wai5888 commented on GitHub (Sep 30, 2022):

你这是桥接啊,实际上两端都是client,需要一个server 服务开两个端口,把两个client串起来,这种frp是实现不了的,你其实需要的是一个tcp client转tcp server,这样另一个tcp client就可以连接这个sever端口了。

目前的FRPC是不支持,所以希望作者评估一下能不能做。因为反代使用的socket应该是可以bind端口的。

<!-- gh-comment-id:1263024779 --> @Wai5888 commented on GitHub (Sep 30, 2022): > 你这是桥接啊,实际上两端都是client,需要一个server 服务开两个端口,把两个client串起来,这种frp是实现不了的,你其实需要的是一个tcp client转tcp server,这样另一个tcp client就可以连接这个sever端口了。 目前的FRPC是不支持,所以希望作者评估一下能不能做。因为反代使用的socket应该是可以bind端口的。
Author
Owner

@fatedier commented on GitHub (Sep 30, 2022):

考虑:

  1. 真实的使用场景是什么?是否有其他的替代方案。
  2. 是否有其他知名的反向代理的项目提供这样的能力,例如 nginx,envoy 等等,可以作为参考。
  3. 一味地增加功能会让应用变得冗余和难于理解、维护,尽量只考虑通用的标准的能力,或者大多数用户需求的能力。
<!-- gh-comment-id:1263039807 --> @fatedier commented on GitHub (Sep 30, 2022): 考虑: 1. 真实的使用场景是什么?是否有其他的替代方案。 2. 是否有其他知名的反向代理的项目提供这样的能力,例如 nginx,envoy 等等,可以作为参考。 3. 一味地增加功能会让应用变得冗余和难于理解、维护,尽量只考虑通用的标准的能力,或者大多数用户需求的能力。
Author
Owner

@Wai5888 commented on GitHub (Sep 30, 2022):

1、这个场景确实比较少见,常用于P2P。主要是被代理的应用需要明确知道报文的地址信息(IP地址、端口),判断是否与之前配置一致。我这边刚好就有这样的应用。
2、目前我知道nginx采用的也是使用随机端口访问被反代的服务器。
3、其实这个功能也依旧是原有的功能,仅仅只是在创建socket的使用,要走一个分支,需要指定端口则bind,不需要则使用随机端口

<!-- gh-comment-id:1263042802 --> @Wai5888 commented on GitHub (Sep 30, 2022): 1、这个场景确实比较少见,常用于P2P。主要是被代理的应用需要明确知道报文的地址信息(IP地址、端口),判断是否与之前配置一致。我这边刚好就有这样的应用。 2、目前我知道nginx采用的也是使用随机端口访问被反代的服务器。 3、其实这个功能也依旧是原有的功能,仅仅只是在创建socket的使用,要走一个分支,需要指定端口则bind,不需要则使用随机端口
Author
Owner

@github-actions[bot] commented on GitHub (Feb 16, 2024):

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

<!-- gh-comment-id:1947559958 --> @github-actions[bot] commented on GitHub (Feb 16, 2024): Issues go stale after 21d of inactivity. Stale issues rot after an additional 7d of inactivity and eventually close.
Author
Owner

@Wai5888 commented on GitHub (Feb 20, 2024):

回复一下,激活此issue

<!-- gh-comment-id:1953338299 --> @Wai5888 commented on GitHub (Feb 20, 2024): 回复一下,激活此issue
Author
Owner

@fatedier commented on GitHub (Feb 20, 2024):

综合考虑上面的几个问题,这个 feature 不在计划之中,如果有需求,建议结合其他工具使用,例如转发给一个其他的代理,再由支持此功能的代理通过指定的本地端口访问。

<!-- gh-comment-id:1953406341 --> @fatedier commented on GitHub (Feb 20, 2024): 综合考虑上面的几个问题,这个 feature 不在计划之中,如果有需求,建议结合其他工具使用,例如转发给一个其他的代理,再由支持此功能的代理通过指定的本地端口访问。
Author
Owner

@github-actions[bot] commented on GitHub (Mar 13, 2024):

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

<!-- gh-comment-id:1992839633 --> @github-actions[bot] commented on GitHub (Mar 13, 2024): Issues go stale after 21d of inactivity. Stale issues rot after an additional 7d of inactivity and eventually close.
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#2491
No description provided.