mirror of
https://github.com/fatedier/frp.git
synced 2026-05-15 08:05:49 -06:00
[GH-ISSUE #4693] [Feature Request] 使用nginx反向代理frps时,客户端使用proxy protocol无法获取真实ip的问题 #3707
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#3707
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 @1332881954 on GitHub (Mar 4, 2025).
Original GitHub issue: https://github.com/fatedier/frp/issues/4693
Describe the feature request
流量路径:浏览器->云服务器nginx(port 80)->frps (vhostHTTPPort 7080)->frpc->内网nginx
问题描述:公网服务器上nginx监听80端口,nginx反向代理frps的7080端口,frpc上开启proxy_protocol_v2,访问时,内网nginx服务器$proxy_protocol_addr获取到的ip总是为127.0.0.1
配置文件:
公网nginx:
frps:
frpc:
内网nginx:
Describe alternatives you've considered
个人猜测问题的原因在于真正请求frps的是本机上的nginx(80端口反向代理7080),因此frps认为用户ip为127.0.0.1,修改云服务器nginx的proxy_pass一行(例如[::1],云服务器内网ip 10.78.xx.xx等),发现内网nginx获取到的proxy_protocol的ip也会随之改变。
这种设计其实本身没有问题,但是我想问一下有没有一种方法可以将客户端的ip传递过去,例如在反向代理的时候增加一项配置(或者直接读取X-Real-IP),可以额外将客户端的ip发送给frps,frps使用此地址作为proxy protocol的source ip,而不是实际请求frps的ip。搜索了相关issue,没有找到一个很好的解决方案,thanks!
Affected area
@xqzr commented on GitHub (Mar 4, 2025):
使用
X-Forwarded-Forhttps://gofrp.org/zh-cn/docs/features/common/realip/
Nginx http 模块
proxy_pass不支持 Proxy Protocol