How to expose your localhost server to the internet?

Hey there! Are you wondering how you can expose a server or an application that you have running locally to the internet without spending money to host it in a public domain? You've come to the right place. Today we'll explore the use of a piece of software called ngrok.

What is ngrok?

Ngrok is a service that creates a private secure tunnel connection to the ngrok cloud. The localhost server is now mapped to the ngrok.io sub-domain which a remote user can access. This service does not require you to expose ports in your network, or even setup port forwarding. The ngrok client software is available for Windows, macOS, and Linux.

How to get ngrok?

To start, open ngrok.com in your browser and click Sign up to register. A Google or GitHub account is easiest, but you can choose standard registration with an email address and password. An email verification link will be sent to you.

After login, you’ll be directed to the ngrok dashboard where you can download the client for your operating system. ng_rock1

Download and extract the file, following any specific instructions for your OS. It’s then necessary to add your authentication token by running the command shown in the Connect your account section a little further down the page.
ng_rock_2

./ngrok authtoken <token>

How to Use ngrok

Launch your web application using its normal start command, then note the port and whether it’s running on http or https. To start a new tunnel, run:
./ngrok <protocol> <port>
For example, if your site is served on http://localhost:8888, enter:
./ngrok http 8888

The terminal will clear and show the status with two Forwarding http and https addresses, such as http://123456789.ngrok.io/. You can pass either URL to another person so they can access your application from anywhere. The terminal shows a log of requests while ngrok is active.
ng_rok_terminal

The ngrok status panel panel at dashboard.ngrok.com/endpoints/status also shows a list of currently active URLs and client IP addresses. (You may need to refresh the browser to update it.)
ng_rok_status

Once you’ve finished, quit ngrok by pressing Ctrl | Cmd + C in your terminal. Further help and options are available by entering:

./ngrok help
Hope this helps! ☺️

Source: https://www.sitepoint.com/use-ngrok-test-local-site/

Previous
Previous

Kubernetes Pods

Next
Next

Kubernetes - Weave Network Overlay