1. Home
  2. Docs
  3. Ethereum General
  4. Secure ETH Node

Secure ETH Node

Securing your Ethereum Nodes

1. Choosing a Strong Random Password For Accounts

Choose a strong and random password when creating accounts on either Parity or Geth. One can generate password from the following sites:

  1. https://passwordsgenerator.net/
  2. https://lastpass.com/generatepassword.php
  3. https://www.random.org/passwords/

2. Using Nginx HTTP basic Auth

Installing Nginx

sudo apt-get update

sudo apt-get install nginx

You can access the default Nginx landing page to confirm that the software is running properly by visiting your server’s domain name or public IP address in your web browser.

If you do not have a domain name set up for your server, you can learn how to set up a domain with DigitalOcean here.

If you do not have a spare domain name, or have no need for one, you can use your server’s public IP address. If you do not know your server’s IP address, you can get it a few different ways from the command line.

Try typing this at your server’s command prompt:

ip addr show eth0 | grep inet | awk ‘{ print $2; }’ | sed ‘s/\/.*$//’

You will get back one or two lines. You can try each in your web browser to see if they work.

An alternative is typing this, which should give you your public IP address as seen from another location on the internet:

curl http://icanhazip.com

When you have your servers IP address or domain, enter it into your browser’s address bar:


You should see the default Nginx landing page, which should look something like this:

Nginx default page

This is the default page included with Nginx to show you that the server is installed correctly.

ubuntu 14.04, by default, Nginx automatically starts when it is installed.

Step Three — Manage the Nginx Process

Now that you have your web server up and running, we can go over some basic management commands.

To stop your web server, you can type:

sudo service nginx stop

To start the web server when it is stopped, type:

sudo service nginx start

Restart service again, type:

sudo service nginx restart

We can make sure that our web server will restart automatically when the server is rebooted by typing:

sudo update-rc.d nginx defaults

This should already be enabled by default, so you may see a message like this:

System start/stop links for /etc/init.d/nginx already exist.

This just means that it was already configured correctly and that no action was necessary. Either way, your Nginx service is now configured to start up at boot time.

Setting HTTP Auth basic credentials

In this step, you’ll create a password for the user running the node.

That password and the associated username will be stored in a file that you specify. The password will be encrypted and the name of the file can be anything you like.

$ sudo htpasswd -c /etc/nginx/.htpasswd nginx

You can check the contents of the newly-created file to see the username and hashed password.

$ cat /etc/nginx/.htpasswd

Updating the Nginx Configuration

Now that we have created the HTTP basic auth credential, the next step is to update Nginx configuration to see it.

$ sudo nano /etc/nginx/sites-available/default

Update the file to contain these contents

server {

listen 80;

listen [::]:80;

# ADDED THESE TWO LINES FOR AUTHENTICATIONauth_basic “Protected Ethereum client”;auth_basic_user_file /path/to/passwords;

server_name example.com; location / {

     proxy_pass http://localhost:8545/;

     proxy_set_header Host $host; 




To apply the changes, first reload Nginx.

$ sudo service nginx reload

You can now access the RPC url at



You can also install a free SSL certificate that can be gotten from letsencrypt you can find the tutorial here. 

Step 1 — Installing Certbot

First, add the repository.

sudo add-apt-repository ppa:certbot/certbot

You’ll need to press ENTER to accept. Then, update the package list to pick up the new repository’s package information.

sudo apt-get update

And finally, install Certbot’s Nginx package with apt-get.

sudo apt-get install python-certbot-nginx

Certbot is now ready to use, but in order for it to configure SSL for Nginx, we need to verify some of Nginx’s configuration.

Step 2 — Setting up Nginx

Certbot can automatically configure SSL for Nginx, but it needs to be able to find the correct server block in your config. It does this by looking for a server_name directive that matches the domain you’re requesting a certificate for.

If you’re starting out with a fresh Nginx install, you can update the default config file. Open it with nano or your favorite text editor.

sudo nano /etc/nginx/sites-available/default

Find the existing server_name line and replace the underscore, _, with your domain name:

. . .

server_name example.com www.example.com;

. . .

Save the file and quit your editor.

Then, verify the syntax of your configuration edits.

sudo nginx -t

If you get any errors, reopen the file and check for typos, then test it again.

Once your configuration’s syntax is correct, reload Nginx to load the new configuration.

sudo systemctl reload nginx

Certbot will now be able to find the correct server block and update it. Next, we’ll update our firewall to allow HTTPS traffic.

Step 3 — Allowing HTTPS Through the Firewall

If you have the ufw firewall enabled, as recommended by the prerequisite guides, you’ll need to adjust the settings to allow for HTTPS traffic. Luckily, Nginx registers a few profiles with ufw upon installation.

You can see the current setting by typing:

sudo ufw status

It will probably look like this, meaning that only HTTP traffic is allowed to the web server:


Status: active

To                         Action From

—                         —— —-

OpenSSH                    ALLOW Anywhere                  

Nginx HTTP                 ALLOW Anywhere                  

OpenSSH (v6)               ALLOW Anywhere (v6)             

Nginx HTTP (v6)            ALLOW Anywhere (v6)

To additionally let in HTTPS traffic, we can allow the Nginx Full profile and then delete the redundant Nginx HTTP profile allowance:

sudo ufw allow ‘Nginx Full’

sudo ufw delete allow ‘Nginx HTTP’

Your status should look like this now:

sudo ufw status


Status: active

To                         Action From

—                         —— —-

OpenSSH                    ALLOW Anywhere

Nginx Full                 ALLOW Anywhere

OpenSSH (v6)               ALLOW Anywhere (v6)

Nginx Full (v6)            ALLOW Anywhere (v6)

We’re now ready to run Certbot and fetch our certificates.

Step 4 — Obtaining an SSL Certificate

Certbot provides a variety of ways to obtain SSL certificates, through various plugins. The Nginx plugin will take care of reconfiguring Nginx and reloading the config whenever necessary:

sudo certbot –nginx -d example.com -d www.example.com

This runs certbot with the –nginx plugin, using -d to specify the names we’d like the certificate to be valid for.

If this is your first time running certbot, you will be prompted to enter an email address and agree to the terms of service. After doing so, certbot will communicate with the Let’s Encrypt server, then run a challenge to verify that you control the domain you’re requesting a certificate for.

If that’s successful, certbot will ask how you’d like to configure your HTTPS settings.


Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access.


1: No redirect – Make no further changes to the webserver configuration.

2: Redirect – Make all requests redirect to secure HTTPS access. Choose this for

new sites, or if you’re confident your site works on HTTPS. You can undo this

change by editing your web server’s configuration.


Select the appropriate number [1-2] then [enter] (press ‘c’ to cancel):

Select your choice then hit ENTER. The configuration will be updated, and Nginx will reload to pick up the new settings. certbot will wrap up with a message telling you the process was successful and where your certificates are stored:



 – Congratulations! Your certificate and chain have been saved at

   /etc/letsencrypt/live/example.com/fullchain.pem. Your cert will

   expire on 2017-10-23. To obtain a new or tweaked version of this

   certificate in the future, simply run certbot again with the

   “certonly” option. To non-interactively renew *all* of your

   certificates, run “certbot renew”

 – Your account credentials have been saved in your Certbot

   configuration directory at /etc/letsencrypt. You should make a

   secure backup of this folder now. This configuration directory will

   also contain certificates and private keys obtained by Certbot so

   making regular backups of this folder is ideal.

Your certificates are downloaded, installed, and loaded. Try reloading your website using https:// and notice your browser’s security indicator. It should indicate that the site is properly secured, usually with a green lock icon. 

Test Server : https://www.ssllabs.com/ssltest/

Let’s finish by testing the renewal process.

Step 5 — Verifying Certbot Auto-Renewal

Let’s Encrypt’s certificates are only valid for ninety days. This is to encourage users to automate their certificate renewal process. The certbot package we installed takes care of this for us by running ‘certbot renew’ twice a day via a systemd timer. On non-systemd distributions this functionality is provided by a script placed in /etc/cron.d. This task runs twice a day and will renew any certificate that’s within thirty days of expiration.

To test the renewal process, you can do a dry run with certbot:

sudo certbot renew –dry-run

If you see no errors, you’re all set. When necessary, Certbot will renew your certificates and reload Nginx to pick up the changes. If the automated renewal process ever fails, Let’s Encrypt will send a message to the email you specified, warning you when your certificate is about to expire.

Was this article helpful to you? Yes No

How can we help?