Making a localhost web server public using Ngrok as HTTPS
When I was working on a project, I needed to expose my local web server to debug our application during client testing and to test it in real-time.
For a specific requirement, I had to make my web app accessible over HTTPS. Although I tried searching on Google for a solution, I found it challenging to find the right one. This article aims to provide a quick solution to this problem.
To meet this requirement, I utilized an application called Ngrok. You can download this tool from the link provided below.
Next, sign up for the same website because they will create a separate hosting environment for you to host your localhost environment. Then, navigate to your account, where you will find your Auth token.
Running the following command in your Ngrok instance will add your Auth token to the default ngrok.yml
configuration file. This step will grant you access to more features and longer session times. The running tunnels will be listed on the endpoints page of the dashboard.
ngrok config add-authtoken --your auth token--
Even though there are some example commands on the Ngrok website, I couldn’t find a way to host HTTPS URLs. Below I have attached accurate command to make a web app public as HTTPS URL.
ngrok http https://localhost:8080 --host-header="localhost:8080"
You can use any port number instead of port 8080.
After running the above command, Ngrok creates a public HTTPS URL for you (arrow mark URL).
Anyone with this link can access your localhost web server.