Deploy TaskMuncher React App to AWS

Deploy TaskMuncher React App to AWS

by John Vincent

Posted on November 18, 2018

This is part of a series of discussions regarding Deploying TaskMuncher.

For more details, please see Deploy TaskMuncher

Amazon Web Services

Deploy TaskMuncher to AWS

Use domain for the exercise.

Thus, Nginx server name is johnvincentio

Create EC2 Instance

  • Login to AWS
  • Go to AWS Dashboard
  • Services
  • EC2
  • Instances (left nav)
  • Launch Instance (button)

Step 1: Image type

  • Ubuntu Server 16.04 LTS (HVM), SSD Volumn Type, 64-bit (x86). Ensure is Free Tier eligible.

Step 2: Instance Type

  • General Purpose, t2.micro, Free Tier eligible, 1 cpu, 1 Gb Memory
    • Next>

Step 3: Configure Instance Details

  • Next>

Step 4: Add Storage

  • Next>

Step 5: Add Tags

  • Next>

Step 6: Configure Security Group

Assign a security group

  • Create a new security group

Add, without changing values:

  • HTTP

  • Review and Launch>

Step 7: Review Instance Launch

  • Launch>

Select an existing key pair or create a new key pair

  • Create a new key pair
  • Key Pair Name: taskmuncher
    • Download Key Pair

Note the public DNS and public IP.

The instance is launched and will be available when the instance state is running

Configure SSH

Copy taskmuncher.pem to ~/.ssh

cd .ssh

List Extended Attributes

xattr taskmuncher.pem

which provides a list of extended attributes.

To remove attributes

xattr -d extended-attribute file

for example

xattr -d taskmuncher.pem
xattr -d taskmuncher.pem

Set security

chmod 400 taskmuncher.pem

Test SSH

ssh -vvv -o IdentitiesOnly=yes -i /Users/jv/.ssh/taskmuncher.pem

Note that user for Ubuntu volume is ubuntu

This should connect.

If get

The authenticity of host ' (' can't be established.
ECDSA key fingerprint is SHA256:uc+xtpZbAyLmHe14Om00Y3aI4Sug08ZmleKX0je84co.
Are you sure you want to continue connecting (yes/no)?

reply yes

Basic user configuration

  • Add user jv
    • sudo adduser {remote-user}
    • {password}
  • Root privileges
    • sudo usermod -aG sudo {remote-user}

Create bin directory

su - {remote-user}
mkdir bin .ssh

Add bin to PATH and add aliases

su - {remote-user}
vi .profile



lf() { ls -FaC $*; }

Copy authorized keys

sudo cp /home/ubuntu/.ssh/authorized_keys /home/jv/.ssh/authorized_keys

sudo -s
cd /home/jv/.ssh
chown jv:jv authorized_keys

Basic root configuration

Add aliases to root

sudo -s
vi /etc/bash.bashrc

lf() { ls -FaC $*; }

SSH Config File

Add to ~/.ssh/config

## taskmuncher droplet at AWS
Host awstaskmuncher
    UseKeychain yes
    AddKeysToAgent yes
    User jv
    IdentityFile ~/.ssh/taskmuncher.pem

Add to ~/.ssh/add_all

ssh-add -K taskmuncher.pem

Add to Keychain


Make SSH Script


# script to ssh into the AWS taskmuncher
echo "Script to ssh into the AWS taskmuncher"
echo " "
echo " "
echo "Remote Server: $REMOTE_SERVER"
echo " "
echo "Completed"

Test SSH script



Always backup SSH keys.

Update Ubuntu Server

sudo apt-get update

did not retrieve any updates, just gets package information.

sudo apt-get dist-upgrade

A new version of /boot/grub/menu.lst is available, but the version installed currently has been locally modified.

Keep the local version currently installed.
sudo reboot


Select Instance from From AWS Dashboard

  • Actions, Instance State, Reboot


Setup a firewall using Set Up a Basic Firewall


Add Swap using Add Swap

Install Basics

Install Basics using Install Basics

Install Node and Npm

Install Node and Npm using Install Node and Npm

Install PM2

Install PM2 using Install PM2

Install HTML-Minifier

Install HTML-Minifier using Install HTML-Minifier

Install Mongo Ubuntu

Install Mongo Ubuntu using Install Mongo Ubuntu

Install Ubuntu Nginx

sudo chown jv:jv .config

Install Ubuntu Nginx using Install Ubuntu Nginx

Configuring Google Domains

Use domain:

From EC2 dashboard, instance ip:

Configuring Google Domains using Configuring Google Domains

Configure HTTP Nginx

Configure HTTP Nginx using Configure HTTP Nginx

  • User: jv
  • Group: jv
  • Server:
  • Nginx web server: /var/www/johnvincentio

Create SSL Certificates

Create SSL Certificates using Create SSL Certificates

sudo letsencrypt certonly -a webroot --webroot-path=/var/www/johnvincentio/html -d -d
sudo vi /etc/nginx/snippets/


ssl_certificate /etc/letsencrypt/live/;
ssl_certificate_key /etc/letsencrypt/live/;

Configure HTTPS Nginx

sudo vi /etc/nginx/sites-available/https/johnvincentio

Configure HTTPS Nginx using Configure HTTPS Nginx

First time deploy TaskMuncher React App to AWS

Copy useful files to AWS

scp my_files

First time deploy TaskMuncher React App to AWS using First time deploy TaskMuncher React App to Digital Ocean



Ensure login is working and data is accessible.

Production Issues

Some production problems with resolutions

Disk Full

df -h shows /dev/xvda1 is full.

Large directories

Look for large directories, then drill down to find the culprits.

sudo du -x / | sort -n | tail -40

/home/jv/clones is over 600M

Large files

Look for troublesome files

sudo find / -type f -size +5M -exec ls -lh {} \;


find / -type -f -size +1M

Look for huge files

sudo find / -type f -printf '%12s %p\n' 2>/dev/null|awk '{if($1>999999999)print $0;}'

will show some basic culprits.


Log Files

sudo du -s /var/log/* | sort -n

Log files /var/log, and tmp /tmp are probably safe to delete, most of them. If do so, find processes with delete files

lsof | grep deleted

then reboot.

Remove Unused files

sudo apt-get update
sudo apt autoremove

This may happen a number of times

A new version of /boot/grub/menu.lst is available, but the current version installed currently has been locally modified

What would you like to do about menu.lst?

This is always the answer

Keep the local version currently installed


Swap is 4GB, may be I should make this smaller.