Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ProxyProtocol support #111

Closed
AmandaJonesAway opened this issue May 21, 2022 · 8 comments
Closed

ProxyProtocol support #111

AmandaJonesAway opened this issue May 21, 2022 · 8 comments

Comments

@AmandaJonesAway
Copy link

I'm wondering if it is possible to somehow support passing originating IP/port via Proxy Protocol ?
https://www.haproxy.com/blog/haproxy/proxy-protocol/
I currently have apache passing the connection over to a wstunnel --server instance, which in turn forwards the tcp session to another host on the LAN; The final host now only ever sees the IP of the webserver - the software I'm running supports incoming proxy protocol v2, if it detects the header on connection, so if there is a way to add this (presumably based on whatever apache passes over in the headers) then it'd help enormously in identifying the end-users.
Thanks!

@erebe
Copy link
Owner

erebe commented May 23, 2022

Wstunnel already print X-Forwarded-For header if present, https://github.com/erebe/wstunnel/blob/master/src/Tunnel.hs#L226
Is this not enough ?

@AmandaJonesAway
Copy link
Author

This appears in the log, on the server where the wstunnel -server is running, but is not passed on to the final service accepting the connection - this only sees the connection as coming from the IP of the webserver, and has no information as to where it originated. Adding a proxy-protocol header would allow that data to be passed onwards to be logged against the user records on the service using an existing and reasonably well supported mechanism.

@AmandaJonesAway
Copy link
Author

I should note that I run a game server, which has both sessions that may last many hours, and resource fetches that last mere moments. It can be very hard to identify which entry in the webserver's log relates to which session on the game server, as the log doesn't include the outgoing port number which I could at least then tie up to the source port on the game server's log, so my only means of tying them together at the moment is by the time initial connection / login occurs, which is relatively course, and might be ambiguous when load is high.

It /should/ only need an appropriate header constructing from the data you have (in, e.g., any X-Forwarded-For) and sending out once ahead of the outgoing connection. But, this is low priority even for me, and I don't expect it to be worked on; just putting it forward as a feature request in case it would be of use to others also.

@erebe
Copy link
Owner

erebe commented May 24, 2022

Haha ok, sorry I read your first message too quickly, I thought you wanted wstunnel server to support proxy protocol from an upstream reverse proxy.

Seems fun to implement, I will try to do it when I have time (which I don't have much those days).
Do you need support for the protocol V1 (text) or V2 (binary) ?

@AmandaJonesAway
Copy link
Author

AmandaJonesAway commented May 24, 2022 via email

@erebe
Copy link
Owner

erebe commented Jan 12, 2024

It has been a long time, but it should be supported now. You can pass to your tcp tunnel -L tcp://1212:192.168.0.1:443?proxy_protocol to send header v2 at the beginning of the connection.

it is in pre-release https://github.com/erebe/wstunnel/releases/tag/v9.1.0

@AmandaJonesAway
Copy link
Author

Many thanks! I will update and test, and report back, as soon as I have some free time. (I am confident it will be fine, but I'm always prepared to be surprised by software..)

@erebe
Copy link
Owner

erebe commented Jan 22, 2024

feel free to re-open if needed

@erebe erebe closed this as completed Jan 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants