How to set up private RPC server on Debian / Ubuntu
- 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
andnet
, meanwhile it blocks access to dangerous RPC methods, e.g.admin
orpersonal
--http.corsdomain "*"
allows your RPC endpoint to be used in dApps in all domains
If you want your RPC endpoint to provide archive 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 recommendation: all private RPC endpoints should be named bpx-dataseed
, so if your domain is yourdomain.com
, please name your RPC server bpx-dataseed.yourdomain.com
.
3. Install nginx HTTP server and certbot:
apt-get install nginx python3-certbot-nginx
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. Let the BPX developers know that you host your own RPC endpoint. If it works stably for a few months, we will post information about it on our website and social media.