Create Custom Endpoint Cosmos

Prepare Domain and Subdomain

Install Packagee

sudo apt autoremove nodejs -y
curl -fsSL https://deb.nodesource.com/setup_16.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 

Prepare set Custom API and RPC

** example (change .planqd)
nano $HOME/.planqd/config/app.toml
  • on API Configuration change false to enable

  • and save on your notepad API local 0.0.0.0:1417

**example (change .planqd)
nano $HOME/.planqd/config/config.toml
  • and save on your notepad RPC local 127.0.0.0:14657

SET VARIABLE

API_DOMAIN=YOUR_API_DOMAIN
RPC_DOMAIN=YOUR_RPC_DOMAIN
API_IP_PORT=IP:PORT
API_RPC_PORT=RPC:PORT

CREATE CONFIG

Config For API

sudo cat <<EOF > /etc/nginx/sites-enabled/${API_DOMAIN}.conf
server {
    server_name $API_DOMAIN;
    listen 80;
    location / {
        add_header Access-Control-Allow-Origin *;
        add_header Access-Control-Max-Age 3600;
        add_header Access-Control-Expose-Headers Content-Length;

	proxy_set_header   X-Real-IP        \$remote_addr;
        proxy_set_header   X-Forwarded-For  \$proxy_add_x_forwarded_for;
        proxy_set_header   Host             \$host;

        proxy_pass http://$API_IP_PORT;

    }
}
EOF

Config For RPC

sudo cat <<EOF > /etc/nginx/sites-enabled/${RPC_DOMAIN}.conf
server {
    server_name $RPC_DOMAIN;
    listen 80;
    location / {
        add_header Access-Control-Allow-Origin *;
        add_header Access-Control-Max-Age 3600;
        add_header Access-Control-Expose-Headers Content-Length;

	proxy_set_header   X-Real-IP        \$remote_addr;
        proxy_set_header   X-Forwarded-For  \$proxy_add_x_forwarded_for;
        proxy_set_header   Host             \$host;
	
	proxy_http_version 1.1;
        proxy_set_header Upgrade \$http_upgrade;
        proxy_set_header Connection "upgrade";

        proxy_pass http://$RPC_IP_PORT;

    }
}
EOF

Config Test

sudo pkill nginx
nginx -t 

Outputt if test ok

Install Certificate SSL

sudo certbot --nginx --register-unsafely-without-email
sudo certbot --nginx --redirect -d ${API_DOMAIN},${RPC_DOMAIN}

Done

*** For GRPC settings it is the same as above

Last updated