Running your own Insight explorer

From DigiByte Wiki
Jump to: navigation, search

Here are some quick and dirty instructions on how to run your own Insight explorer, similar to DigiExplorer.info

This is useful if you want the API's to be able to access for integrating external products in to the blockchain


System requirements

You will need a Linux server with at least 4GB of RAM (6GB preferred) and a 50GB HDD (as of early 2019).

You obviously need to be mildly familiar with the command line and setting these things up.

While this will work on CentOS etc, this presumes a Debian / Ubuntu server

Instructions

Start with the following as root

apt-get install python curl build-essential screen git nginx software-properties-common

This will give you some basic tools needed

Installing certbot for ssl

We are going to install the basics now for certbot so you will be running a free SSL certificate

add-apt-repository universe
add-apt-repository ppa:certbot/certbot
apt-get update
apt-get install certbot python-certbot-nginx
certbot --nginx

Follow the Certbot instructions for your domain.

Basic installation

If you don't already have one, create a DigiByte user for this to be run as:

useradd digibyte -m -s /bin/bash
su - digibyte

Now that you are the DigiByte user, you'll want to run the following:

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash

After you've run this, log out of the DigiByte user and then log back in again for the changes to your profile to take effect

exit
su - digibyte

Now we proceed with the installation of the Insight explorer:

nvm install v8.10.0
npm install -g digibyte-node
cd explorer
digibyte-node install insight-digibyte-api
digibyte-node install insight-digibyte-ui

You can now start the DigiByte explorer by running digibyte-node start however we don't want to do that just yet.

nano -w ~/explorer/digibyte-node.json

Tidying up the URL

We're going to adjust where it serves up the API details etc, so that you don't have to browse http://server:3001/insight/ for everything, so that we can setup the nginx reverse-proxy later. You want the file to look like the following:

{
  "network": "livenet",
  "port": 3001,
  "services": [
    "digibyted",
    "insight-digibyte-api",
    "insight-digibyte-ui",
    "web"
  ],
  "servicesConfig": {
    "digibyted": {
      "spawn": {
        "datadir": "./data",
        "exec": "/home/digibyte/.nvm/versions/node/v8.10.0/lib/node_modules/digibyte-node/bin/digibyted"
      }
    },
  "insight-digibyte-ui": {
   "routePrefix": "",
   "apiPrefix": "api"
   },
  "insight-digibyte-api": {
   "routePrefix": "api",
   "enableCache": true
   }
  }
}

Adding in those last insight-digibyte-ui and insight-digibyte-api settings.

Now, run:

screen

This will put you into a screen session so you can keep it running once you disconnect. Alternatively look to install pm2 to manage the process

Once inside the screen session, run:

cd ~/explorer
digibyte-node start

You should now be able to browse to http://server:3001/ and be greeted with a syncing Insight explorer

Finishing the nginx reverse-proxy

That's great, but you don't want to keep having to use port 3001, and you want HTTPS, so we'll setup nginx to handle the rest. Time to edit your nginx config:

nano -w /etc/nginx/sites-enabled/default

Under the Default Server configuration you'll see server_name, set this to be your URL, such as:

server_name explorer-1.us.digibyteservers.io;

You also want to add:

        location / {
        proxy_pass http://localhost:3001;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
        }

If you already have a "location /" then you can comment it out with a # at the start of the line.

Also, be sure to comment out:

#try_files $uri $uri/ =404;

If it's still in there and uncommented.

Once saved you can then run:

/etc/init.d/nginx restart

This will restart your nginx server and you should be able to browse to https://server/ and have it display your Insight explorer

You can also test the API's by browsing to: https://server/api/addr/DD2GiYVo3uL7SBmg5jtXDxfYZhdzGt3kRx?noTxList=1

For reference it should look like: https://explorer-1.us.digibyteservers.io/api/addr/DD2GiYVo3uL7SBmg5jtXDxfYZhdzGt3kRx?noTxList=1