How to install an Ethereum online node with HTTPS
Ubuntu 16.04
fallocate -l 4G /swapfile
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
Make it permanent
nano /etc/fstab
Add
/swapfile none swap sw 0 0
apt-get install software-properties-common
add-apt-repository -y ppa:ethereum/ethereum
apt-get update
apt-get install ethereum
nohup geth --light --testnet --rpc --rpcaddr "IP_TO_EXPOSE_IF_NO_SSL" --rpccorsdomain "*" --ipcdisable &
For testnet network
nohup geth --testnet &
For main network
nohup geth &
For fast sync
nohup geth --fast
For light node (download only header)
nohup geth --light &
Enable localhost rpc
nohup geth --rpc --rpccorsdomain "*" &
Enable rpc and expose it to an IP
nohup geth --rpc --rpcaddr "IP_OF_SERVER" --rpccorsdomain "*" &
See geth output
tail -f nohup.out
Check if geth is running
ps ax | grep geth
Kill geth
pkill geth
apt-get install nginx
nano /etc/nginx/sites-enabled/default
Replace by (replace SERVER_ADDRESS)
server {
listen 80;
listen [::]:80;
location /.well-known {
root /var/www/DOMAIN/;
}
location / {
return 301 https://$host$request_uri;
}
}
server {
listen 443 ssl default_server;
listen [::]:443 ssl default_server;
#ssl_certificate /etc/letsencrypt/live/DOMAIN/fullchain.pem;
#ssl_certificate_key /etc/letsencrypt/live/DOMAIN/privkey.pem;
#ssl_trusted_certificate /etc/letsencrypt/live/DOMAIN/chain.pem;
location / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
# Fix the “It appears that your reverse proxy set up is broken" error.
proxy_pass http://localhost:8545;
proxy_read_timeout 90;
}
}
Note that the ssl_certificate config are commented. As the certificate is not generated yet, Nginx will not restard if the files doesn't exist. We will uncomment them later.
service nginx restart
apt-get install letsencrypt
mkdir /var/www/DOMAIN/
letsencrypt certonly --webroot -w /var/www/DOMAIN/ -d DOMAIN
nano /etc/nginx/sites-enabled/default
Uncomment the lines like:
ssl_certificate /etc/letsencrypt/live/DOMAIN/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/DOMAIN/privkey.pem;
ssl_trusted_certificate /etc/letsencrypt/live/DOMAIN/chain.pem;
service nginx restart
First try to check if the renew work
letsencrypt renew --dry-run --agree-tos
Don't mind the Registering without email!
.
If everything is fine, add the cron
crontab -e
Add
37 4 * * * letsencrypt renew >/dev/null 2>&1
https://github.com/ethereum/go-ethereum/wiki/Installation-Instructions-for-Ubuntu
https://certbot.eff.org/#ubuntuxenial-nginx
https://github.com/ethereum/go-ethereum/wiki/Command-Line-Options
https://www.digitalocean.com/community/tutorials/how-to-add-swap-on-ubuntu-14-04