How to deploy a Writer Node on LacChain - Turupawn/Producers GitHub Wiki

In this guide we are going to deploy a Writer node on the LacChain blockchain without Orion support using Ubuntu 10.04 LTS. Keep in mind the IP used is 147.182.178.194 and the Orion password used is abc so change acordingly.

Also, keep in mind in this guide we conect via ssh using a .pem file. So in order to convert your .ppk into a .pem file you will need to run something like sudo puttygen private_key.ppk -O private-openssh -o yourkey.pem.

1. Do this from your Local Machine

a. Install dependencies

On local machine:

sudo apt-get update
sudo apt-get install software-properties-common
sudo apt-add-repository ppa:ansible/ansible
sudo apt-get update
sudo apt-get install ansible
git clone https://github.com/lacchain/besu-network
cd besu-network/

b. Upload Oracle's Java from your local machine to your remote machine

Go to https://www.oracle.com/java/technologies/javase-jdk11-downloads.html and download Oracle's Java by selecting Linux x64 Compressed Archive.

Upload it to the remote server:

scp -i yourkey.pem jdk-11.0.11_linux-x64_bin.tar.gz [email protected]:

2. Setup your remote machine

a. Connect your local machine and install Java

ssh -i yourkey.pem [email protected]
sudo mkdir -p /var/cache/oracle-jdk11-installer-local
sudo cp jdk-11.0.11_linux-x64_bin.tar.gz /var/cache/oracle-jdk11-installer-local/
sudo apt update

b. And open some ports

sudo nano /etc/nginx/conf.d/ssl.conf

server {

  listen 80;
  listen [::]:80;
  server_name 147.182.178.194;

  location ^~ /ws {
      proxy_http_version 1.1;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection "upgrade";
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header Host localhost;
      proxy_set_header X-NginX-Proxy true;
      proxy_pass http://localhost:4545;
  }

  location / {
      proxy_http_version 1.1;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection "upgrade";
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header Host localhost;
      proxy_set_header X-NginX-Proxy true;
      proxy_pass http://localhost:4545;
      proxy_set_header  Access-Control-Allow-Origin *;
  }
}
sudo ufw allow 60606/tcp
sudo ufw allow 60606/udp
sudo ufw allow 4545/tcp
sudo ufw reload
sudo ufw enable

3. Back to your local machine

a. Setup deploy files

cd besu-network
cp inventory.example inventory
nano inventory

Edit the following under the [writer] section:

[writer]
147.182.178.194 node_ip=147.182.178.194 password=abc node_name=honduras-lac-node node_email=your@email

b. Deploy

ansible-playbook -i inventory --private-key=./yourkey.pem -u forge site-lacchain-writer.yml

Once deployed, look for the enode message that should look something like this:

ok: [147.182.178.194] => {
    "msg": "enode://YOUR ENODE HERE"
}

Setup a reverse proxy for the RPC commands

Let's edit the Nginx configuration file..

sudo nano /etc/nginx/conf.d/ssl.conf

Let's modify as follows.

server {

  listen 80;
  listen [::]:80;
  server_name 147.182.178.194;

  location ^~ /ws {
      proxy_http_version 1.1;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection "upgrade";
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header Host localhost;
      proxy_set_header X-NginX-Proxy true;
      proxy_pass http://localhost:4545;
  }

  location / {
      proxy_http_version 1.1;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection "upgrade";
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header Host localhost;
      proxy_set_header X-NginX-Proxy true;
      proxy_pass http://localhost:4545;
      proxy_set_header  Access-Control-Allow-Origin *;
  }
}

Now we can access the RPC commands via port 80 trough the Nginx reverse proxy.

Take a look at the oficial documentation here.