Home > Software engineering >  Expose client behind NAT to internet by using a public reverse-proxy (with access to the internet)
Expose client behind NAT to internet by using a public reverse-proxy (with access to the internet)

Time:12-15

I want to understand the theory of exposing clients behind NATs via a public server, for example to use the client as a proxy (preferably SOCKS5). It would be ideal to find a ready solution but theory would good enough.

To point out what I mean. The client behind the NAT does not directly listen on TCP. It just opens up a TCP connection to the public server which should expose the client. The SOCKS5 proxy on client behind NAT is not directly exposed so the dialed TCP connection should somehow behave like a TCP listener.

If a client behind NAT connects to a public server, how do other users connect and how should I forward the requests?

I think basically it's the same technique that TeamViewer is using:

"When establishing a session, TeamViewer determines the optimal type of connection. After the handshake through our master servers, a direct connection via UDP or TCP is established in 70% of all cases (even behind standard gateways, NATs and firewalls). The rest of the connections are routed through our highly redundant router network via TCP or https tunneling. You do not have to open any ports in order to work with TeamViewer."

But how exactly?

CodePudding user response:

To summarize, for a proxy server in golang, you have to

  1. Create a server that listens to requests with some parameters.
  2. When a request is received, it will make the request to the desired address.
  3. Then it will return the response to the original client in the private network.
  • Related