Skip to main content

How to set up private RPC server on Debian / Ubuntu

  1. Set up and sync your BPX Chain full node following this guide. When creating the execution client systemd service, add some new parameters to the geth command line:
ExecStart=bpx-geth --syncmode snap --http --http.api web3,eth,net --http.corsdomain "*"
  • --http.api web3,eth,net makes only safe APIs available to the public: web3, eth and net, meanwhile it blocks access to dangerous RPC methods, e.g. admin or personal
  • --http.corsdomain "*" allows your RPC endpoint to be used in dApps in all domains

If you want to run anyour RPC endpoint providingto provide archive states,data also, replace the mentioned line to the following one:

ExecStart=bpx-geth --syncmode full --gcmode archive --http --http.api web3,eth,net --http.corsdomain "*"

2. Create an A record in your domain DNS zone and point it to your BPX full node IP address.

BPX developers recommend thatrecommendation: all private RPC endpoints should be named bpx-dataseed, so if your domain is example.yourdomain.com, please name your RPC server bpx-dataseed.example.yourdomain.com.

3. Install nginx HTTP server and certbot - a tool to get free SSL certificate:certbot:

apt-get install nginx python3-certbot-nginx

3.4. Configure nginx as a reverse proxy for Geth:

nano /etc/nginx/sites-available/bpx-dataseed.yourdomain.com
upstream geth {
        least_conn;
        server 127.0.0.1:8545;
}

server {
        server_name bpx-dataseed.yourdomain.com;

        location / {
                proxy_pass http://geth;
        }
}

Save file and exit.

5. Enable site and restart nginx:

ln -s /etc/nginx/sites-available/bpx-dataseed.yourdomain.com /etc/nginx/sites-enabled/bpx-dataseed.yourdomain.com
systemctl restart nginx

6. Obtain a free SSL certificate from Letsencrypt to enable HTTPS:

certbot --nginx -d bpx-dataseed.yourdomain.com

During the certbot wizard, provide your e-mail address for notifications related to the certificate, then select the option to redirect all HTTP traffic to HTTPS.

7. Done. Test your RPC endpoint by adding https://bpx-dataseed.yourdomain.com instead of the public RPC address in your wallet, e.g. Metamask.