MDSLab / wstun

Tunnels and reverse tunnels over WebSocket
Apache License 2.0
114 stars 44 forks source link

Expose a local server behind NAT to internet #25

Open snimavat opened 4 months ago

snimavat commented 4 months ago

Looks like the reverse proxy mode can be used to expose a local server behind NAT to be exposed to internet

Eg. a server running on wsclient can be exposed to internet using reverse proxy.

Examples about how to run a reverse tunnel client:

//without security
./wstun.js -r6666:2.2.2.2:33 ws://server:8080

//with security 
./wstun.js -r6666:2.2.2.2:33 wss://server:8080

In the above examples, the client asks the server to open a TCP server on port 6666 and all connections on this port are tunneled to the client that is directely connected to 2.2.2.2:33.

In above example, i am not clear, what is tunneled to the client that is directely connected to 2.2.2.2:33

What is 2.2.2.2 ? I want to expose a server on 127.0.0.1:LOCALPORT

flongo82 commented 3 months ago

Hello, the server should be running on a frontier machine with a public IP address on one side and an interface on a LAN on the other. In the example, the server is reachable at the endpoint ws://server:8080 where server is the public IP address. You are asking the server to open port 6666 and tunnel all the traffic to a computer on the LAN reachable at IP address 2.2.2.2 on port 33.

You can expose a service running on the server. Just use localhost or 127.0.0.1:localport after the first :