September 10, 2026

How to setup and run a secure Ethereum node – Mohammad Hasan Mazrooei

How to setup and run a secure Ethereum node – Mohammad Hasan Mazrooei

How to setup and run a secure Ethereum node – Mohammad Hasan Mazrooei

How to setup and run a secure Ethereum node – Mohammad Hasan Mazrooei

I decided to install Nginx from Ubuntu PPA. To do so, do the following:

sudo apt install software-properties-common -y
sudo add-apt-repository ppa:ondrej/nginx
sudo apt update
sudo apt install nginx -y

After installing Nginx, You need to edit the default configuration file with your favorite editor. I use nano.

sudo echo "" > /etc/nginx/sites-enabled/default
sudo nano /etc/nginx/sites-enabled/default

Now insert these lines into the file:

server 
}

From now, all RPC requests are sent to Geth from Nginx. For example, You want to check whether the node is syncing or not:

curl -X POST x.x.x.x:80 
--data ''
-H 'Content-Type: application/json'

Everything is set and ready, but Your node is still not secure and everyone can send RPC requests and might steal your Ether.

To make it secure, We need to add basic authentication to Nginx. I usually use apache2-utils package.

sudo apt install apache2-utils -y
sudo htpasswd -c /etc/nginx/.ethereum username

After Running the command above, you need to enter your desired password twice to confirm. If You view the contents of the file, You will see something like this:

username:$apr1$6wbFPLba$zP3QQq8FYeslDn3UU5Sfy0

It’s time to edit Nginx configuration file and add our authentication commands:

server 
}

You can see the difference.

Now if You send a RPC request, You get 401 error that requires authentication. So You must add username and password to Your request:

curl -X POST -u username:password x.x.x.x:80 
--data ''
-H 'Content-Type: application/json'

Now You have a secure Ethereum node with Nginx help.

If You have any questions, I’d be glad to help You.

Published at Thu, 01 Aug 2019 07:30:46 +0000

Bitcoin Pic Of The Moment
By CashlessWay – Global Hub for ePayment Culture on 2014-06-28 09:38:52
tags

Previous Article

How to setup and run a secure Ethereum node – Mohammad Hasan Mazrooei

Next Article

Bitcoin Will Make Peter Schiff Kick Himself: Gold Bug Debates Pompliano