Xray 被 Nginx 反代时 如何获取客户端的源端口? #4419
Unanswered
Benjamin1919
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
服务端配置环境是 Nginx 监听 443 端口,然后反代 Xray。
Nginx 日志中 $remote_addr, $remote_port 都能正常记录,但是 Xray 日志里只能看到客户端源 IP,源端口都是 0 (无论 xhttp 还是 httpupgrade 都是这样)。
无论设置什么样的 header (X-Client-Port, X-Real-Port, X-Forwarded-Port ) 都不能让 Xray 获取到正确的源端口。
问了一下 ChatGPT,回答说 Xray 只能从传输层获取四元组信息(源IP地址、源端口号、目标IP地址、目标端口号),而 Nginx 反代是在应用层,因此不能正确传递客户端源端口。但是 Xray 可以获取到正确的源 IP,这就很奇怪。
如果无法通过 header 传递,还有没有其他办法让 Xray 获取到客户端的源端口呢?
而且由于 http 是应用层,也无法通过 proxy_protocol 向 Xray 传递四元组信息。
使用 Nginx 的 stream 模块既可以反代 Xray 又可以启用 proxy_protocol,但是不能通过 path 分流。
不知道大家有没有其他办法?
Beta Was this translation helpful? Give feedback.
All reactions