How to setup a Ethereum POA (private-proof-of-authority-ethereum-network) network on Amazon AWS (2nd Part)
By: Akshay Pilankar
Tags: Nginx, Ethereum Blockchain, Blockchain, Certbot, Geth

Hello, as promised I am back with 2nd part of this tutorial where I will cover Url wrapper & SSL support with NGINX and Certbot.

Let's begin with revising what we have done till now in the last tutorial

EC2 instance (server) setup. Geth installation and private network setup. Nginx and Certbot installation.

In case you have missed, here are the commands to install and setup Nginx and Certbot

sudo apt-get update

sudo apt install nginx

sudo ufw enable

sudo ufw allow 'Nginx Full'

sudo ufw allow 'OpenSSH'

sudo add-apt-repository ppa:certbot/certbot

sudo apt install python-certbot-nginx

sudo ufw status

now check the status

OutputStatus: activeTo Action From

-- ------ ----

OpenSSH ALLOW Anywhere

Nginx Full ALLOW Anywhere

OpenSSH (v6) ALLOW Anywhere (v6)

Nginx Full (v6) ALLOW Anywhere (v6)

then check for Nginx service — systemctl status Nginx

Output● nginx.service - A high performance web server and a reverse proxy server

Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)

Active: active (running) since Fri 2018-04-20 16:08:19 UTC; 3 days ago

Docs: man:nginx(8)

Main PID: 2369 (nginx)

Tasks: 2 (limit: 1153)

CGroup: /system.slice/nginx.service

├─2369 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;

└─2380 nginx: worker process

Now we have everything installed let’s concentrate on how to do port forwarding with NGINX. open default file using nano or your favorite editor.

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

As per the previous tutorial we are using rpcport 8501 and wsport 8601 in private network. so here will forward port 80 (server IP) to 8501 and 8601. add the following command Inside the default file. copy-paste it to the last line of the file.

server {

server_name blockchain. echttech.co.in ; #your domain name #remove any http://



location /ws {

proxy_pass http://localhost: 8601 ;

proxy_http_version 1.1;

proxy_set_header Upgrade $http_upgrade;

proxy_set_header Connection "upgrade";

proxy_set_header Host $http_host;

proxy_set_header X-Real-IP $remote_addr;

}



location / {

proxy_set_header X-Forwarded-For $remote_addr;

proxy_set_header Host $http_host;

proxy_pass http://localhost: 8501 ;

}

}

Save and close the file when you are finished. Now restart Nginx to enable your changes.

sudo systemctl restart nginx

Nginx should now be serving your domain name. You can test this by opening new CMD in local machine and connecting to ethereum geth console with geth attach http://blockchain.echttech.co.in , where you should see geth console for private network.

To check WS provider use geth attach ws://blockchain.echttech.co.in/ws

Note — you have to open port 80 and 443 in order for this to work from AWS console.

The next step is to Obtaining an SSL Certificate. The Nginx plugin will take care of reconfiguring Nginx. To use this plugin, type the following:

sudo certbot-nginx -d blockchain.echttech.co.in

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.

Output 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. this will reload the Nginx. Again you can test this by opening new CMD in local machine and connecting to ethereum geth console with following commands

To check HTTPS provider geth attach https://blockchain.echttech.co.in To check WS provider use geth attach wss://blockchain.echttech.co.in/ws

Let’s Encrypt’s certificates are only valid for ninety days. use this command to renew certificates.

sudo certbot renew --pre-hook "systemctl nginx stop" --post-hook "systemctl nginx start"

Good work!!!!

So far we have successfully set up Nginx and Certbot.

In next part will setup blockchain explorer. Stay tuned!

smash like button and share!!!!!