How to install and setup Ngrok for private server installations? (updated 2019)

How to install and setup Ngrok for private PWSLab installations? (updated 2019)

Introduction

Ngrok is one of the most popular tunnel service platform through which you can easily expose your local servers (like PWSLab installations) which are behind NATs/Firewalls to the public internet over secure tunnels.

It connects to the ngrok cloud service which accepts traffic on a public address and relays that traffic through to the ngrok process running on your machine and then on to the local address you specified.

Features of Ngrok

  1. You can instantly create a public HTTP/HTTPS URL for an application like PWSLab running locally in your server machine.
  2. Their tunnels are very fast and works on HTTP/2 protocol which actually speeds up your loading.
  3. You can even protect your tunnel with the help of HTTP Basic Authentication.
  4. With the help of web based portal, you can easily inspect (Request/Response) all the incoming traffic to your tunnel.
  5. You don’t need to do any kind of port forwarding while using Ngrok.
  6. You can even expose your network service to the internet with the help of TCP tunneling.
  7. Multiple simulatenously tunnels can be worked.
  8. Websocket support is also available.

How to setup install and setup Ngrok

Step 1 – Create a Free Account on Ngrok.com, basically you can create an account on Ngrok by three ways.
  1. With your personal Email
  2. With Github
  3. With Gmail
Step 2 – After confirming the account with your mail ID, just try to login with the same details which you’ve used while creating the account.

Step 3 – After successful signup, you’ll a Dashboard Page in front of you just like below:


Step 4 – Now you need to download the Ngrok package from the Download Page.
Based on your operating system, you can choose the file and ngrok supports all OS (Windows/Linux/MacOSX).
  1. Windows - For Windows 7, 8, 8.1 and 10
  2. Linux - Ubuntu, CentOS, RedHat
  3. Mac OSX
Use wget https://download-url/ if in case you are downloading Ngrok for a server edition of OS. You can copy the download url from the OS links in the Download page. 
Step 5 – Next step is to install the package which you’ve downloaded from previous step.
  1. To extract the package in Linux/MacOSX – type “unzip /path/to/ngrok.zip” in your command terminal. 
  2. And for Windows, just simply double click on the file and extract the .exe file with the help of Winrar/Winzip.
For Linux installations: Run apt-get install unzip or yum install unzip if unzip tool isn't installed. 
Note: To use Ngrok, run CMD/Terminal/Bash from same directory where you’ve downloaded the Ngrok package.
Step 6 – Furthermore, you also need to connect to ngrok using a secure authtoken.
Run below command to add your account’s authtoken to your ngrok.yml file. Copy the token from the Dashboard as displayed in the screenshot above. 
  1. For Windows - ngrok.exe authtoken <Your Token>
  2. For Linux/OSX - ./ngrok authtoken <Your Token>
Step 7 – Starting your first tunnel
Once you have your local server running, you can open a tunnel to the port where your application is running.
For local web server to internet, type the following in your terminal.
  1. For Windows - ngrok.exe http 80
  2. For Linux/OSX - ./ngrok http 80



Here you can see that, we’ve created a dummy index.php file into our xampp server which can easily be accessed on Internet with the help of Ngrok tunnelling address.
You can also inspect your all incoming HTTP traffic by using their web based portal which you can easily access by opening http://localhost:4040/ in your web browser.



To secure your tunnel you can use -auth switch which enables HTTP basic Auth security on all requests as shown in below command:
  1. For Windows - ngrok.exe http -auth=”username:password” 80
  2. For Linux/OSX - ./ngrok http -auth=”username:password” 80
Now, start sharing and accessing your Public URLs from the Internet with a single click! 
To close the connection, simply close the terminal/CMD where the session is created. 



Have more questions? Please email us at support@peerxp.com
Also, let us know if the article is helpful!