Skip to content

Feat: Support TCP proxy - #258

Closed
nodauf wants to merge 5 commits into
almeidapaulopt:mainfrom
nodauf:feat-TCPProxy
Closed

Feat: Support TCP proxy#258
nodauf wants to merge 5 commits into
almeidapaulopt:mainfrom
nodauf:feat-TCPProxy

Conversation

@nodauf

@nodauf nodauf commented Apr 25, 2025

Copy link
Copy Markdown
Contributor

Hi,

Like several others, I encountered a use case where I needed to connect via SSH to a remote Docker container and proxy raw TCP connections (see issues #252, #242, #221).

This PR introduces support for that feature. When a TCP protocol is specified in the Docker label (e.g. tsdproxy.port.1=22/tcp:22/tcp,no_autodetect), the proxy will use a TCP proxy instead of the default HTTP one.

@patrickwolf

Copy link
Copy Markdown

This PR introduces support for that feature. When a TCP protocol is specified in the Docker label the proxy will use a TCP proxy instead of the default HTTP one.

Thanks. How exciting is this? :) @almeidapaulopt can this be accepted and merged in please? :)

@mkawczynski07

Copy link
Copy Markdown

@nodauf great work! @almeidapaulopt It will be nice to have that merged. I want to use TSD Proxy in my new setup, but I must expose PostgreSQL DB connections. Now it is not possible. Please merge that :)

@patrickwolf

Copy link
Copy Markdown

And I need to access my machines via SSH to connect via VSCode with them and can't do that either yet so can't use TSDProxy for those yet... Please merge :)

@patrickwolf

patrickwolf commented May 19, 2025

Copy link
Copy Markdown

@almeidapaulopt have you had a chance to look at this pull request? i'm needing this functionality every day and just have to deploy a new container and am wondering if i need the old tailscale side car route when I would prefer to use tsdproxy but i just need the ssh support... and in this moment i'm wondering how to build tsdproxy from this PR but obviously would prefer if it was included.

so just sending a gentle nudge your way and thank you for the tool!! :)

@nodauf

nodauf commented May 19, 2025

Copy link
Copy Markdown
Contributor Author

@patrickwolf would you be interesting to test the PR. If you validate the correct implementation and that it work for you, it would maybe help for the review.

@patrickwolf

Copy link
Copy Markdown

Yes I'd be happy to. Could you give me easy instructions on how to turn this PR into a docker container I can use for the test?

@nodauf

nodauf commented May 19, 2025

Copy link
Copy Markdown
Contributor Author

I will try to publish a Docker image this week or the next one, and I'll let you know once it's done.

@almeidapaulopt

Copy link
Copy Markdown
Owner

I will try to publish a Docker image this week or the next one, and I'll let you know once it's done.

Thank you for you contribution, I've made some changes. Can you look at it, please?

@patrickwolf

Copy link
Copy Markdown

Nice I'm excited @almeidapaulopt and @nodauf ... it will make tsdproxy usable in so many more scenarios!!

Comment thread internal/proxymanager/port.go Outdated
@nodauf

nodauf commented Jun 4, 2025

Copy link
Copy Markdown
Contributor Author

All good with the last commit

@nodauf

nodauf commented Jun 4, 2025

Copy link
Copy Markdown
Contributor Author

@patrickwolf So you can test these changes while the PR is waiting to be merged, I've published a Docker image (https://hub.docker.com/r/nodauf/tsdproxy/tags)

This image includes the main feature from this PR and the changes from #260.
You can see the specific commits here:

Let me know if this works for you!

@Zolfax

Zolfax commented Jun 25, 2025

Copy link
Copy Markdown

I've tested your docker image, it works great.
Thank you.
I've specifically tried mounting a samba share from a different location.
This was not possible with the current TSDProxy image.

Usecase is a non-docker server that is part of lists.
Here's my nas.yaml file for reference:

nas:
  proxyProvider: default
  tailscale:
    ephemeral: true
  ports:
    445/tcp:
      targets:
        - tcp://<hostname>:445
    443/https:
      targets:
        - https://<hostname>:8443

@nodauf

nodauf commented Jun 25, 2025

Copy link
Copy Markdown
Contributor Author

Thank you for your feedback

@jukoby

jukoby commented Jul 23, 2025

Copy link
Copy Markdown

Thank you for doing this.
Is this ready to be merged? @almeidapaulopt
I could test it too if it's needed.

@almarzn

almarzn commented Aug 12, 2025

Copy link
Copy Markdown

This project seems unmaintained for now. Maybe we should try and maintain a proper fork?

@subey

subey commented Sep 30, 2025

Copy link
Copy Markdown

It works for me too - thank you!.
Without it, when I tried to connect, I got: "http2: failed reading the frame payload: %!w(), note that the frame header looked like an HTTP/1.1 header"

@patrickwolf

Copy link
Copy Markdown

@patrickwolf So you can test these changes while the PR is waiting to be merged, I've published a Docker image (https://hub.docker.com/r/nodauf/tsdproxy/tags)

Sorry that I have not been able to test it yet. My work pulled me in different directions for now

@mattdale77

Copy link
Copy Markdown

I'm interested in this for git. Commenting so I see updates

@totza2010

Copy link
Copy Markdown

I still hope this code will be integrated and further developed.

@almeidapaulopt

Copy link
Copy Markdown
Owner

Closing this PR — TCP proxy support is already implemented on main. The codebase already has a tcpPort struct in internal/proxymanager/port.go with proper net.Conn-based bidirectional forwarding, context cancellation, and error handling. It's integrated into the port initialization via newPortTCP() in proxy.go:137. The existing implementation is cleaner as it uses standard net.Conn instead of gvisor/gonet.TCPConn, avoiding the heavy gvisor dependency and the type assertion risk. Thank you for the contribution, nodauf!

@mattdale77

Copy link
Copy Markdown

Is there an example somewhere of using docker compose labels to use this feature?

@almeidapaulopt

Copy link
Copy Markdown
Owner

look a https://almeidapaulopt.github.io/tsdproxy/docs/providers/docker-reference/#common-patterns

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.

10 participants