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

[Feature Request] Server listen on Unix socket #201

Open
vercas opened this issue Dec 25, 2023 · 7 comments
Open

[Feature Request] Server listen on Unix socket #201

vercas opened this issue Dec 25, 2023 · 7 comments
Labels

Comments

@vercas
Copy link
Contributor

vercas commented Dec 25, 2023

Specifically for cases where the wstunnel server is behind a reverse proxy, it would be useful to have the ability to listen on a Unix domain socket instead of having to use an IP address and port.
This would only be useful with non-secure ws, e.g. unix:///absolute/path/to/unix/socket or unix://relative/path/to/socket.
Unix domain sockets are subject to filesystem security models and mount namespaces, making them easier to restrict access to than traditional IP/port network endpoints, especially when you have Docker installed on the same system.
A command-line option for specifying the mode of the created socket would be handy too.

@erebe erebe added question and removed question labels Dec 26, 2023
@erebe
Copy link
Owner

erebe commented Dec 26, 2023

Hello,

Would you mind explaining how this facilitates the setup with a docker container ? If I am not mistaken, you can create a network namespace that you can share across multiple container.

@vercas
Copy link
Contributor Author

vercas commented Dec 26, 2023

It's for situations where you can't/won't put wstunnel and nginx in the same network namespace.
A common example is a bastion host - you want the reverse proxy container to only have access to a public facing network, while wstunnel containers would only have access to an internal network.

@pavel-orlov
Copy link

I'd also like to have similar to ssh alternative below.
ssh -N -f -R /tmp/zp3ft5fmps6bd4gep7iv:127.0.0.1:80 user@host

@ha-ku
Copy link

ha-ku commented Jan 9, 2024

This would also help in scenarios like chained proxies, where forwarding via unix sockets seems to have better performance than local network loopbacks.

@erebe
Copy link
Owner

erebe commented Jan 12, 2024

Hello,

Would you mind trying this pre-release https://github.com/erebe/wstunnel/releases/tag/v9.1.0 and let me know if it works for you ?
You should be able to start wstunnel client and specify something like -L unix:///tmp//wstunnel.sock:127.0.0.1:80

Regarding wstunnel server supporting receiving packets from a unix socket, I am not sure whether I am going to do it, as it will require a bit too much code change to my taste to support it, and I am not sure if there is a real need for it. Will check and let you know

P.s: I still need to support unix datagram socket, but as everything related to udp, it is a pain to implement.

@pavel-orlov
Copy link

Hello @erebe

Thank you for adding Unix socket support. That works for me with reverse connection. I noticed it does not delete a socket file when connection is finished and unable to reuse the file again, so when you try -R unix:///tmp//wstunnel.sock:127.0.0.1:80 again, the server rejects connection.

@erebe
Copy link
Owner

erebe commented Jan 21, 2024

indeed thanks for reporting, I have made the fix 🙈 b7dbd86

and have re-created the release 9.2.0, so if you re-download it, it should be good now.

@erebe erebe changed the title Listen on Unix socket [Feature Request] Server listen on Unix socket Feb 3, 2024
@erebe erebe added the wont-do label May 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants