Get Public URL for expose your local web server

Access Localhost from anywhere

Are you connected from a remote location? Do you want your localhost accessible by your team? Do you want to use your local webserver with any of the azure services before the deployment? Is your app failing on the AWS platform, don’t know how the flow happens behind the scene? Have you ever felt how good it is to use our local webserver to debug input requests from any other hosted or cloud services or bot services?

I felt several times to expose a local webserver or APIs or databases to the internet. But howww?? Then I found the concept of NGROK.

What is ngrok

Access local servers from the public internet over secure tunnels.

It is a lightweight executable application, reverse proxy software, which creates a secured tunnel to your local environment to expose it to public access. Tunneling is the process of data transfer between the network.

Setup ngrok

  1. Download ngrok
  2. Extract it to get the executable file
  3. Double click to run the ngrok.exe
  4. Fire the localhost by providing the port number on which your application is running on.

For Example,

http://localhost:3000/ => ngrok http 3000

type the ngrok with port in the same ngrok.exe command prompt

It supports both HTTP and HTTPS tunnels. Now Let’s share the link to access your local web server. Since it’s a free plan, the session lasts only a few hours. Use the paid service to get greater control. Note the session expiry timeout in the above snap to aware of the liveliness of or app on the internet.

Track the traffic

Once the user hits the shared link, you get the list of requests in the same command prompt window.

Request Inspection

Hit http://localhost:4040 to debug the HTTP request and response traffic.

introspection of HTTP requests and responses

Navigate to any endpoint to view the Header, Raw, and binary details. Scroll down to view the response object. use Replay option to debug or to analyze it further.

Run hosted bot service in the emulator

Not only to expose localhost to the internet, but it is also helpful to run any hosted application in the Emulator. Have you worked with a chatbot or used bot services in the AWS/Azure? Then OFCOURSE below use case will be helpful for you to debug the hosted URL.

Bot Framework Emulator is an application that allows bot developers to test and debug either locally or remotely. Without tunneling software, you will not receive replies from the bot which is already in production.

Click the settings icon at the bottom left corner.
Enter the ngrok.exe path
Save it.
After a few seconds, verify the tunnel status.

Done!! Now you can run hosted or production bot app service from the bot framework emulator.

Protect the application

Do you like to protect access to your publicly hosted local server? Auth parameter does the magic. To popup the HTTP auth credential window on the screen to access your site, use the following command.

To bind a tunnel with HTTP authentication, you need to sign up and get an auth token from your dashboard.

Happy Reading!!!



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store