genshen / wssocks

socks5 over websocket
MIT License
152 stars 28 forks source link

Feature Request: Permit reverse proxy #41

Open chrisjd20 opened 3 years ago

chrisjd20 commented 3 years ago

So this is a great program. But what I would love is a reverse socks tunnel feature. So that you could have a client connect to a server and bind a local port on the server to listen and tunnel into the client's network. This is great if you have a client that doesnt have a public IP but you need to be able to reach into it's network. This is equivalent to ssh's -R option:

ssh -R 9050 bob@blah.blah
genshen commented 3 years ago

Currently, wssocks indeed does not support reverse proxy directly.
But wssocks+ssh can be a workaround.
Consider you have a web service on the client (at port :9050), and server has a public IP (e.g. pub.server.com).

In traditional approach, if client can connect to server via ssh directly, we can use ssh -R, just like:

client_host$ ssh -NR pub.server.com:9051:localhost:9050 user@pub.server.com

Then, we can access client's web service via curl http://pub.server.com:9051/.

If client can not connect to server via ssh directly (but can connect using wssocks), then the ssh reverse proxy can be changed to:

client_host$ ssh -o ProxyCommand='nc -x 127.0.0.1:1080 %h %p' -NR pub.server.com:9051:localhost:9050 user@pub.server.com

(where port :1080 above is wssocks client's port for data forwarding)

May this workaround can help you.

Native reverse proxy support of wssocks can be a really useful feature, I would consider to implement it.

chrisjd20 commented 3 years ago

Thats definitely a possible work around but not on Windows system with specific restrictions.