How do I use ngrok on the BB-400?

FAQs

This FAQ will discuss ngrok and how you can use it on the BB-400.

Using ngrok in a factory

What is ngrok?

ngrok is a useful tool to add a locally running web interface/API onto the internet, securely. This is possible using the port number of the web interface/API.
Please refer to the ngrok documentation for further information: https://ngrok.com/docs.

Benefits of ngrok

  • Allows any IP address or port number
  • A free account is available
  • The setup process is quick and simple
  • Requests can be replayed via a button on the UI (PRO Account)

Setting up ngrok on your BB-400

The next section will explain how to set up ngrok on your BB-400 and configure it for use.

1. Sign up for a ngrok account

The first step is to sign up for a free ngrok account at the following link: https://dashboard.ngrok.com/signup.

Create an ngrok account

2. Download ngrok

Next, ngrok needs to be downloaded (https://ngrok.com/download) so that you can install and set it up on your preferred operating system. This FAQ will be using the Linux(ARM) setup to install ngrok onto the BB-400.

First, log in to your BB-400 either from the terminal in the UI or alternatively, you can use PuTTY or a different terminal emulator:

Connected to BB-400 Cockpit

After opening the terminal in your device’s web interface, you will be in the /home/bb directory of your BB-400. If you would like to download the ngrok file into a different location please change your directory.

On the ngrok download page, right-click on Linux(ARM) and copy the link for download:

Download ngrok

A “wget” command can be used to download the Linux(ARM) file from the ngrok website directly onto your BB-400.

As you can see from the image above, the link currently is “https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-arm.tgz” but this may change in the future. Replace the /LINUX/ARM/LINK.tgz part of the command below with the Linux(ARM) file download link that you have copied:

$ wget /LINUX/ARM/LINK.tgz

For our example the command would be:

$ wget https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-arm.tgz


NB: The link above may be subject to change. Double-check the link available here.

3. Unzip the ngrok folder

In your terminal type in the command shown below to unzip the ngrok folder:

$ tar xf ngrok-stable-linux-arm.tgz

4. Connect your ngrok account

Now enter the command shown below to add your unique authentication key:

ngrok Authtoken

You’ll receive confirmation that the command has been successful:

Installation successful message

5. Setup complete!

You have successfully set up ngrok on your BB-400 and now you are ready to configure a webpage to forward through.

Using ngrok on your BB-400

The next section of the FAQ will show a few examples of how you can use ngrok on your BB-400. A step-by-step guide for each scenario will be provided.

1. Forwarding Cockpit through ngrok

The port number for Cockpit is 9090.
In the terminal, type:

$ ./ngrok http 9090

You will see a terminal UI with an HTTP forwarding URL and further information about the connection made:

Forwarding session

Copy and paste this URL into a browser and you now have access to your device’s cockpit:

Forwarded Cockpit

You must close the ngrok connection successfully before closing the terminal connection.
To do this, within your terminal, type: ctrl+c and the server will close the connection to Cockpit.
If you do not close the ngrok connection before closing the terminal and you try to use ngrok again you will get an error saying the connection is still open and you will have to reboot your BB-400:

Cockpit disconnected

2. Forwarding a webpage of a device that the BB-400 is connected

By using a BB-400 and ngrok, webpages of other devices such as a PLC or a Brainboxes’ ED device can be forwarded to the internet securely. The PLC or ED device can be connected to either the LAN, Uplink or Wi-Fi port. As long as the device is reachable from the BB-400 it can be forwarded securely through ngrok.

Flow diagram

In this example, I will be using an ED-588 to demonstrate forwarding a webpage, but any ED device can be used.

Connect the ED device to the BB-400’s LAN port, this means that the device will not be assigned an IP address by DHCP. Instead, the device will default to an IP address of 192.168.127.254 after 30 seconds. This is on the same subnet as the BB-400’s LAN port.

To access the webpage of the ED, when on the same subnet, simply type the device’s IP address into a search engine. However, when accessing the device from a PC which is on the ‘x.x.0.x’ subnet, a connection would not be possible.

With ngrok, it is possible to access the ED device’s UI, using the device’s IP address and port number (which in this case is 80). For the ED-588 type in the following command into a terminal:

$ ./ngrok http 192.168.127.254:80

You will see a terminal UI with an HTTP forwarding URL and further information about the connection made:

Session connections

Copy and paste the URL into a browser and you now have access to the ED-588’s UI page:

ED-588 device page

To close the connection type in ctrl+c in the terminal where ngrok is running.
The browser will show a message to confirm that the connection has been closed:

ngrok not found

This FAQ has provided a step-by-step guide on how to download and set up ngrok on your BB-400. It has also demonstrated some examples of using ngrok on your BB-400.

FAQs