feat: support passing proxy_protocol to reality backend#2693
Open
aJC7737 wants to merge 1 commit into
Open
Conversation
wwqgtxx
force-pushed
the
Alpha
branch
2 times, most recently
from
April 16, 2026 02:31
46220ad to
e0a42d4
Compare
Author
|
New implementation a573147 vs the old 032a2fe and even older 25e89e2 Compared with the earlier implementation, this revision keeps the same user-facing config surface but improves correctness and maintainability:
|
wwqgtxx
force-pushed
the
Alpha
branch
5 times, most recently
from
May 15, 2026 10:13
61b8d7f to
17bed79
Compare
wwqgtxx
force-pushed
the
Alpha
branch
3 times, most recently
from
June 12, 2026 02:06
f513c49 to
d67572b
Compare
Add a reality-config.proxy-protocol option for Reality inbound listeners. When enabled, mihomo writes a PROXY protocol v1/v2 header to the Reality fallback dest connection so reverse proxy backends can recover the original client source IP and port.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TL;DR: This change adds
proxy-protocolsupport to Reality inbound so backends (for example NGINX) can see the original client source address.Summary
This PR adds optional PROXY protocol support for Reality inbound fallback traffic.
A new
reality-config.proxy-protocoloption is added:0: disabled, default1: send PROXY protocol v12: send PROXY protocol v2When enabled, mihomo records the accepted client connection's source and local destination addresses, then writes the selected PROXY protocol header immediately after connecting to the Reality
destbackend. This allows reverse proxy backends such as nginx to see the original client source IP and port instead of only seeing the mihomo-side connection.The backend must be configured to accept PROXY protocol. Otherwise, the fallback TLS/HTTP traffic will be parsed incorrectly by the backend.
Implementation Notes
proxy-protocolto Reality inbound config parsing.RemoteAddr()andLocalAddr()in the Reality context.dest.github.com/pires/go-proxyprotofor standards-compliant v1/v2 header generation.proxy-protocolvalues during config build.UNKNOWN/LOCALand logs a warning instead of failing the fallback connection.Testing