Do you know localtunnel or ngrok? These are services, that let you expose a local application server to the public internet. Essentially they are proxy servers, but allow to the public to access your local machine. I found that some VPN services also support such feature via port forwarding.
It stuck under my nails for a while and now I also implemented such a service. My tool consist of two js files. One is the proxy server the other the proxy client. The proxy server you can run on your public machine. In a local network you first run the service you want to expose, such as a web application you are developing. Using the proxy client, you are able to connect to the proxy server and ask for a port. On the public server, a tcp server get started and everything the incoming connections send to the proxy server get first pushed to the proxy client and from there to the destination service.
Each, the proxy server and the proxy client have been implemented in just 60 lines of code. To be honest, 60 pretty dense lines of code. But just using node.js without extra dependencies. It was pretty tough and made my head spin a little, implementing such an infrastructure piece. all the time, it is connection connections, proxy connection, client connection, destination connection. A tool to manage connections.
The current implementation is for such kind of a tool, definitely on the simple side and I can see, why it can be useful, simply to buy an account from ngroc. Because, the code still need some polishing, it would be good if the proxy server can support sub-domains not just selecting a port. And also provide certificates would be nice.
If you like, you can download the code here as a .zip.