Node.js forwarding from local network to public Internet

forwardinginternetnode.js

I have a Server running node.js in my network that is not reachable via the internet (i.e., no static IP / domain).
However, I have a vServer with a domain that is running node.js as well. Can I forward data from the local server to the public domain? If so, what is the best practice in doing this?

First thing that came to my mind was using websockets on both the local machine and the public machine and forward new data (local->public vserver). Is that a feasible solution or are there better options?

Best Answer

If there are only Node.js servers involved standard net module should be sufficient.

The instance that is on public domain creates a socket and listen for incoming connections. And then another one, located at the private network, may establish a connection to it.

WebSocket implementation could also be used, see https://stackoverflow.com/questions/16392260/which-websocket-library-to-use-with-node-js for more information. Additional details is required to tell which would be more appropriate for your needs.