DongQN
  • ☑️0G Validator Node
  • ☑️0G Storage Node
    • ☑️Update Storage Node
  • ☑️0G Storage KV
    • ☑️Update 0G Storage KV
  • ☑️0G DA Node
    • ☑️Update 0G DA Node
  • ☑️0G DA Client
  • ☑️Initia-Testnet
  • ☑️XRPL EVM-Testnet
  • ☑️Allora Full Node (RPC)
  • ☑️Hedge-Tesnet
  • ☑️Symphony Validator Node
  • ☑️Aaron Network Validator
  • ☑️Story Validator Node
  • ☑️Empe Validator Node
  • ☑️Nillion Validator Node
  • ☑️Gensyn Testnet Node CPU
  • Reference
    • API Reference
      • Pets
      • Users
  • How to Set Up Explorer
Powered by GitBook
On this page

How to Set Up Explorer

PreviousUsers

Last updated 2 months ago

Install Dependencies

sudo apt autoremove nodejs -y
curl -fsSL https://deb.nodesource.com/setup_19.x | sudo -E bash -
curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --dearmor | sudo tee /usr/share/keyrings/yarnkey.gpg >/dev/null
echo "deb [signed-by=/usr/share/keyrings/yarnkey.gpg] https://dl.yarnpkg.com/debian stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt update
sudo apt install nginx certbot python3-certbot-nginx nodejs git yarn -y

NGINX Configuration

Create an NGINX configuration file for your explorer:

sudo nano /etc/nginx/sites-enabled/explorer.dongqn.com

Replace explorer.dongqn.com with your site's name, for example:

Create this sample configuration:

server {
    listen       80;
    listen  [::]:80;
    server_name explorer.dongqn.com;

    location / {
        root /usr/share/nginx/html;
        index  index.html index.htm;
        try_files $uri $uri/ /index.html;
    }

    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }

    gzip on;
    gzip_proxied any;
    gzip_static on;
  
 }

Remember to replace server_name with your server's name.

SSL Configuration

Install Certificate SSL

sudo certbot --nginx --register-unsafely-without-email

Select option 2 and press Enter. If the BOT asks for redirection, choose YES.

After completion, you can restart NGINX:

sudo systemctl restart nginx

Explorer Configuration

Clone the Repository

cd $HOME
git clone https://github.com/dongqn/explorer.git

Build the Explorer

Navigate to the explorer directory, install dependencies, and build:

cd $HOME/explorer
yarn && yarn build

If you encounter any issues, use the following command:

yarn install --ignore-engines
cd $HOME/explorer
yarn && yarn build

Copy the Web Files to the Nginx HTML Folder

sudo cp -r $HOME/explorer/dist/* /usr/share/nginx/html
sudo systemctl restart nginx

RPC and API Setup Guide

Installing Dependencies and Setting Up Nginx

Connect to your Node and execute the following commands to install Nginx:

sudo apt -q update
sudo apt -qy install curl git jq lz4 build-essential snapd unzip nginx
sudo apt -qy upgrade

API Nginx Configuration File Creation

Create a configuration file for your API:

sudo nano /etc/nginx/sites-available/api-testnet-nillion

Inside the file, it's time to enter the necessary configuration for your API subdomain. Below is a template designed specifically for a Node.js application. Make sure you understand each directive and modify it to fit the specific needs of your application, especially the proxy_pass directive, which should point to the port your application is running on:

server {
    listen 80;
    server_name api-testnet-nillion.dongqn.com;

    location / {
        add_header Access-Control-Allow-Origin *;
        add_header Access-Control-Max-Age 3600;
        add_header Access-Control-Expose-Headers Content-Length;
        
        proxy_pass http://127.0.0.1:1317;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}

Replace api-testnet-nillion.dongqn.com with your domain in the server_name section, and adjust the port number in the proxy_pass directive if necessary (default is 1317). This setup instructs the server to listen on port 80, the default for HTTP. The server_name should match your project's subdomain. The proxy_pass directive is crucial as it tells NGINX where to route requests entering this subdomain.

Creating Your RPC Nginx Configuration File

Similarly, create a configuration for your RPC:

sudo nano /etc/nginx/sites-available/rpc-testnet-nillion

Enter the configuration, replacing api-testnet-nillion.dongqn.com with your domain and adjusting the proxy_pass for your RPC port (default is 26657).

Activating Your Configuration

After tailoring the configuration file to your needs and saving your changes, the next step is to link this file to the sites-enabled directory to activate it:

sudo ln -s /etc/nginx/sites-available/* /etc/nginx/sites-enabled/

This command creates a symbolic link between the sites-available and sites-enabled directories, effectively activating your configuration.

Finally, test your NGINX configuration for syntax errors:

sudo nginx -t

If the test passes without issues, reload NGINX to apply the changes:

sudo systemctl reload nginx

Your subdomains should now be set up and accessible via the specified subdomain addresses. This setup enhances the structure of your project by creating a clear distinction between different parts of your application, facilitating developers and users to interact with your endpoints.

However, all your endpoints are still using unsecure HTTP. In the next section, we'll install SSL for all our endpoints.

SSL Configuration

sudo certbot --nginx --register-unsafely-without-email