mirror of
https://github.com/fatedier/frp.git
synced 2026-05-15 08:05:49 -06:00
[GH-ISSUE #2156] 远程请求记录真实的 IP 地址 #1717
Labels
No labels
In Progress
WIP
WaitingForInfo
bug
doc
duplicate
easy
enhancement
future
help wanted
invalid
lifecycle/stale
need-issue-template
need-usage-help
no plan
proposal
pull-request
question
todo
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/frp#1717
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @heyzqq on GitHub (Dec 18, 2020).
Original GitHub issue: https://github.com/fatedier/frp/issues/2156
The solution you want
远程请求时,都是由本地 127.0.0.1 发起的,无法获取真实 IP。
Alternatives considered
比如 SSH 登陆,如果能记录登陆的真实 IP 地址,哪怕是内网的地址也好,因为看日志无法分辨是谁在尝试登陆。
@heyzqq commented on GitHub (Dec 18, 2020):
@Dagsi commented on GitHub (Dec 18, 2020):
日志能够记录到也好
@heyzqq commented on GitHub (Dec 19, 2020):
嗯,有时候拉黑名单需要。
@heyzqq commented on GitHub (Dec 19, 2020):
既然服务器能拿到 IP,那 frps 应该也是有办法拿到的吧。
@heyzqq commented on GitHub (Dec 19, 2020):
哦哦,明白了。就是即使知道 IP,也没办法利用 IP 在本地 SSH 去限制(那在装 frps 的服务器应该可以限制吧)
还有一个就是,有些需求需要获取访问用户的真实 IP 地址的(比如网站需要记录识别唯一用户),这种不知道在 HTTP 头能不能获取到
@yuyulei commented on GitHub (Dec 21, 2020):
可以在 HTTP 头获取源 IP,可以参考 nginx 的方式。
@yuyulei commented on GitHub (Dec 21, 2020):
@heyzqq 如果是想拿到 ssh 请求方的源 IP,一般日志里确实没有,但是打开 debug 日志后,可以在 frps 的日志里看到对应信息,随便给了个示例图如下:

其中红色涂掉的地址,是用户连接的本地和远端地址,其中后面那个就是用户的 IP。
不知道这样是否已经满足你的要求?其他类型(ssh 外)的代理也是类似的。
注:最后关于 debug 日志,通常是开发人员自己排查问题时候打开的。
@heyzqq commented on GitHub (Dec 21, 2020):
好的谢谢,下次有遇到可以试试。
@shunf4 commented on GitHub (Jan 10, 2021):
能不能把用户的 IP 放到 info 级的日志里?要不然 info 日志里只能看到大量重复的
信息量实在很小。
@zngw commented on GitHub (Jan 11, 2021):
同样希望frps中能记录连接者的ip,最近老是被人暴力破解,一天几千次的 get a new work connection,但又看不是是谁连过来的。后面安装了iptraf,与frps的日志配合查是谁来连接了
@yuyulei commented on GitHub (Jan 12, 2021):
http/https 可以通过获取源 IP ,官方文档中有提到,这里不重复。
针对 非 http/https 的请求临时补充了日志,可以通过 frps 的日志查看类似
作为过渡方案。
@rainbend commented on GitHub (Jan 29, 2021):
Hi @heyzqq 可以试试 https://github.com/arugal/frp-notify, 利用 server manager plugin 将连接信息发送到钉钉
@heyzqq commented on GitHub (Jan 31, 2021):
谢谢,了解一下。