[GH-ISSUE #2486] frps是否支持proxy protocol #1974

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

Originally created by @luyaotang on GitHub (Jul 18, 2021).
Original GitHub issue: https://github.com/fatedier/frp/issues/2486

为了做高可用的保障,现在的网络结构是某台公网服务器上装了haproxy和frps01,frps02。 客户端先连接到haproxy,然后再分通过本地(127.0.0.1)转frps01,frps02。在这种网络结构下,frps就无法感知客户端真实的ip。希望是haproxy可以启用proxy protocol,然后frps获取到客户端真实ip,是否可行?

Originally created by @luyaotang on GitHub (Jul 18, 2021). Original GitHub issue: https://github.com/fatedier/frp/issues/2486 为了做高可用的保障,现在的网络结构是某台公网服务器上装了haproxy和frps01,frps02。 客户端先连接到haproxy,然后再分通过本地(127.0.0.1)转frps01,frps02。在这种网络结构下,frps就无法感知客户端真实的ip。希望是haproxy可以启用proxy protocol,然后frps获取到客户端真实ip,是否可行?
Author
Owner

@fatedier commented on GitHub (Jul 19, 2021):

之后这个真实 IP 会被用在哪里?frps 拿到了这个 IP 之后具体的作用是什么?

<!-- gh-comment-id:882186195 --> @fatedier commented on GitHub (Jul 19, 2021): 之后这个真实 IP 会被用在哪里?frps 拿到了这个 IP 之后具体的作用是什么?
Author
Owner

@luyaotang commented on GitHub (Jul 19, 2021):

查看frpc的客户端IP来源,分析定位。某些情况下,还会做IP约束。

<!-- gh-comment-id:882242418 --> @luyaotang commented on GitHub (Jul 19, 2021): 查看frpc的客户端IP来源,分析定位。某些情况下,还会做IP约束。
Author
Owner

@fatedier commented on GitHub (Jul 19, 2021):

目前支持起来比较复杂,之后如果有可能的话会考虑进去。

<!-- gh-comment-id:882266045 --> @fatedier commented on GitHub (Jul 19, 2021): 目前支持起来比较复杂,之后如果有可能的话会考虑进去。
Author
Owner

@MikoyChinese commented on GitHub (Jul 20, 2021):

See detail in https://github.com/fatedier/frp/issues/2470#issuecomment-878131408

<!-- gh-comment-id:883050606 --> @MikoyChinese commented on GitHub (Jul 20, 2021): See detail in https://github.com/fatedier/frp/issues/2470#issuecomment-878131408
Author
Owner

@luyaotang commented on GitHub (Jul 20, 2021):

See detail in #2470 (comment)

我的跟这些还不一样。我是因为在frps 的监听端口 前置加了haproxy,所以需要frps支持proxy protocol解回来。我的诉求比较简单:我只是需要监听的端口处理能解析proxy protocol,得到原frpc连接时(公网)的IP即可。我已经解决了,有需要的小伙伴可以参考一下:
1)/frp/vendor/github.com/fatedier/golib/net/mux/mux.go

image

<!-- gh-comment-id:883415543 --> @luyaotang commented on GitHub (Jul 20, 2021): > See detail in [#2470 (comment)](https://github.com/fatedier/frp/issues/2470#issuecomment-878131408) 我的跟这些还不一样。我是因为在frps 的监听端口 前置加了haproxy,所以需要frps支持proxy protocol解回来。我的诉求比较简单:我只是需要监听的端口处理能解析proxy protocol,得到原frpc连接时(公网)的IP即可。我已经解决了,有需要的小伙伴可以参考一下: 1)/frp/vendor/github.com/fatedier/golib/net/mux/mux.go ![image](https://user-images.githubusercontent.com/16934367/126336735-827827a6-47fb-4039-b768-a23731a8ccfb.png)
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#1974
No description provided.