Search code examples
node.jsnetwork-programmingmobilevpntunnel

How do I access my local server through public network?


I have a nodejs server working on a raspberry pi. My mobile app should find this server on local network and be able to connect to it and exchange data. But I also should be able to connect, manually, to this server out of local network, in a public one.

I've been looking for tunnels like ngrok, localtunnel etc. But I would like to know if have others ways to do that. Should I use VPN?

I would be glad with help. Thanks!


Solution

  • your local network must have some gateway/router connecting it to the internet - if it's a home network, probably integrated with your cable/dsl/fiber modem or attached router. This gateway holds the public IP of your connection to the internet. It will be to this IP your public connections will need to connect.

    You can configure your network's router to port forward incoming connections on a given port to the internal address of your server. Keep in mind that this means it's open to the wide internet.