Running your own Insight explorer
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.
This page is currently undergoing a re-write for the new Insight version that supports DigiAssets. The legacy instructions are at the bottom for the time being but will be removed very shortly.
Contents
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
Getting started
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.
User account preparation
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 to setup some environment variables:
cat <<EOF >> ~/.profile export INSIGHT_NETWORK='livenet' export BITCOIND_DATADIR=~/.digibyte/ export INSIGHT_FORCE_RPC_SYNC=1 EOF
This allows the Insight service to run on mainnet (It presumes testnet otherwise), with the right directory etc
These changes won't take effect right away,that's fine
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, as well as load the variables we set for Insight earlier.
exit su - digibyte
DigiByte Core
Before we download DigiByte Core, you're going to want to run the following to setup your digibyte.conf:
mkdir -vp ~/.digibyte cat <<EOF > ~/.digibyte/digibyte.conf server=1 maxconnections=300 rpcallowip=127.0.0.1 daemon=1 rpcuser=user rpcpassword=pass txindex=1 EOF
We do this first and foremost because we want to ensure that DigiByte gets started up with the right settings first time around.
Get the latest DigiByte Core from GitHub, 7.17.2 at the time of writing:
wget https://github.com/digibyte/digibyte/releases/download/v7.17.2/digibyte-7.17.2-x86_64-linux-gnu.tar.gz tar xvzf digibyte-7.17.2-x86_64-linux-gnu.tar.gz ./digibyte-7.17.2/bin/digibyted
This should start the DigiByte Core wallet in the background, you can check the progress by running:
tail -f ~/.digibyte/debug.log
You can stop looking at the logs with Ctrl + C, and it won't stop the DigiByte Core service.
Allow DigiByte to fully sync up, it may take a couple of hours depending on your CPU / connection etc
Insight installation
Now we install a specific version of node, as this is the last supported version in that generation:
nvm install v0.10.48
Now we grab the Insight server:
git clone https://github.com/DigiByte-Core/insight.git && cd insight
Now that we have it downloaded, we want to install the other prerequisites:
npm install
Then we're going to sync insight with DigiByte Core. We do this manually on first-run, as it won't resume unless it's 97% sync'd
~/insight/node_modules/insight-bitcore-api/util/sync.js -D -v --rpc
-D tells it to delete the existing data (There shouldn't be any anyways, but in case there's been an issue and you're running this a second time around...)
-v tells it to be verbose
--rpc tells it to use RPC, rather than the index files
This process will likely take 12+ hours, depending on your CPU.
Once completed, you should still be in ~/insight, and so can simply run:
node start
You may also want to run this inside a screen session or use pm2 to monitor it.
As soon as you've run this you can load up http://server.ip:3000 and should be greeted with your Insight server.
Finishing the nginx reverse-proxy
So we're installed and running, but we don't want to keep having to use Port 3000. You also likely want to be using 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:3000; 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
LEGACY (Pre-DigiAssets) 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