How to create RPC,API, and Json-RPC
You must have domain for this step and settup a dns records on cloudflare.com the dns records should be like this

Install depedencies and settup nginx
Connect to your Crossfi Node and 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
Creating Your NGINX Configuration File
sudo nano /etc/nginx/sites-available/crossfi-testnet-api
Configuration nginx for your API subdomain
server {
listen 80;
server_name crossfi-testnet-api.nodevism.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;
}
}
change nodevism.com on server_name with your own domain and change port on proxy_pass with your node port configuration you can find on app.toml
file

RPC
Create your nginx configuration
sudo nano /etc/nginx/sites-available/crossfi-testnet-rpc
Configur your nginx for subdomain RPC
server {
listen 80;
server_name crossfi-testnet-rpc.nodevism.com;
location / {
proxy_pass http://127.0.0.1:26657;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
remember to change server_name nodevism.com
with your domain and proxy_pass
with your node port you can find on client.toml
file

Json-RPC
create you nginx config file
sudo nano /etc/nginx/sites-available/crossfi-testnet-jsonrpc
configure nginx for your json-rpc subdomain
server {
listen 80;
server_name crossfi-testnet-jsonrpc.nodevism.com;
location / {
proxy_pass http://127.0.0.1:8545;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
remember to change server_name nodevism.com
with your domain and proxy_pass
with your node port you can find on app.toml
file

Activate your configuration
sudo ln -s /etc/nginx/sites-available/crossfi-testnet-* /etc/nginx/sites-enabled/
This command creates a symbolic link between the sites-available
and sites-enabled
directories, effectively enabling your configuration.
Finall step, test the 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
all your endpoints are still using unsecure HTTP. In the next section, we'll install SSL for all our endpoints.
Install certbot
I use CertBot as our SSL manager. Install it using the following commands
sudo snap install --classic certbot
sudo ln -s /snap/bin/certbot /usr/bin/certbot
sudo snap set certbot trust-plugin-with-root=ok
SSL configuration
sudo certbot --nginx --register-unsafely-without-email
If everything is done correctly, your API and RPC links should now be working as follows: https://crossfi-testnet-api.nodevism.com https://crossfi-testnet-rpc.nodevism.com
Last updated