Skip to content

Add proxy protocol support#352

Open
shshekhar93 wants to merge 2 commits intorathole-org:mainfrom
shshekhar93:main
Open

Add proxy protocol support#352
shshekhar93 wants to merge 2 commits intorathole-org:mainfrom
shshekhar93:main

Conversation

@shshekhar93
Copy link
Copy Markdown

Adding support for Proxy Protocol V1.

The changes are limited to the server side, which generates and sends the Proxy Protocol header on data channel. The downstream server must be capable of parsing / handling the proxy protocol header.

Alternatively, an additional proxy protocol unwrapping server (for eg. go-mmproxy) could be setup on the client side. In this setup, rathole client's local_addr would point to the go-mmproxy, and go-mmproxy would in turn point to the actual downstream server.

Change log:

  • Added a new boolean field (enable_proxy_protocol) to ServerServiceConfig.
  • Added logic to generate the Proxy Protocol v1 header from TCP Stream.
  • If the enable_proxy_protocol is set as true, the proxy protocol header is written to data channel and flushed, before remainder of downstream protocol specific communication begins.
  • Example for enabling proxy protocol for a service.

Future enhancements:

  • Support Proxy Protocol v2.
  • Perhaps include the go-mmproxy style source IP spoofing logic on the client side to eliminate the needs for special setup on downstream server / go-mmproxy.

@shshekhar93
Copy link
Copy Markdown
Author

shshekhar93 commented Apr 10, 2024

Fixed lint error.

@yujqiao
Copy link
Copy Markdown
Member

yujqiao commented Apr 11, 2024

This is interesting

@pkarc
Copy link
Copy Markdown

pkarc commented Jul 4, 2024

Thanks for the support on this one, I got inspired and did some work over this branch @shshekhar93 supporting v2 as well

rapiz1:rathole:main...pkarc:rathole:proxy-protocol

@amarevite
Copy link
Copy Markdown

What is the status of this feature and the next release? Support for proxy protocol would be very useful to me so I'm looking forward to being able to use it.

@sjtrny
Copy link
Copy Markdown
Contributor

sjtrny commented May 11, 2025

I’ve published a docker image for those that want this feature using code contributed in this thread.

https://github.com/sjtrny/rathole/pkgs/container/rathole

@vnghia
Copy link
Copy Markdown

vnghia commented Jun 18, 2025

Hi everyone, thank you for your contribution. AFAIK, the proxy protocol v2 also supports UDP. Could you add it as well ?

@sneakers-the-rat
Copy link
Copy Markdown

anything that i can do to help push this along into main? looks like we're just stalled out, but the impl looks correct and i still see PRs being merged into this repo. any input from maintainers here on what would be helpful?

@sjtrny
Copy link
Copy Markdown
Contributor

sjtrny commented Sep 15, 2025

any input from maintainers here on what would be helpful?

I think we should resolve packaging/integration issues (e.g. #426 and #428) before adding features. Because if we add the features first we will potentially end up double handling the PRs - first at merge time and then we may have to check/test/review features after making packaging/integration changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants