Difference between revisions of "Running your own Insight explorer"
Dgb chilling (talk | contribs) (Removed older legacy fluff) |
Dgb chilling (talk | contribs) m (Added docker info) |
||
Line 3: | Line 3: | ||
This is useful if you want the API's to be able to access for integrating external products in to the blockchain. | This is useful if you want the API's to be able to access for integrating external products in to the blockchain. | ||
+ | |||
+ | If you want to run this within a Docker container, you can [https://gitlab.com/utarn/digibyte-insight/blob/master/Dockerfile start here instead]. | ||
| |
Revision as of 00:18, 4 August 2019
Here are some quick and dirty instructions on how to run your own Insight explorer, similar to DigiExplorer.info and now including support for DigiAssets
This is useful if you want the API's to be able to access for integrating external products in to the blockchain.
If you want to run this within a Docker container, you can start here instead.
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