Skip to content

Instantly share code, notes, and snippets.

@ghassanmas
Last active December 18, 2020 14:59
Show Gist options
  • Save ghassanmas/9be5530925e0a123fc0c3dcb315e0218 to your computer and use it in GitHub Desktop.
Save ghassanmas/9be5530925e0a123fc0c3dcb315e0218 to your computer and use it in GitHub Desktop.
DevOps on AWS cheatsheet

Cheatsheet for the "DevOps on AWS session".

Important links:

Lists of command we used in the session:

Connectiong to the instance:

chmod 400 path/file.pem // to make the file.pem readonly ssh -i filename.pem user@domain_NameORIpORPublic_DNS // to ssh to the instance

Installing/Configuring Nginx

sudo apt install nginx nginx -v // to make sure all is good, we used "1.8"

Reading Nginx access logs
cat /var/log/nginx/access.log // can be changed in main configuration file.

Directoy of Nginx configuration.
/etc/nginx/nginx.conf // main configuration, applies to all subsevers by default.
/etc/nginx/sites-enabled/default // default ngnix server configuration
To edit sudo nano /path
To view cat /path

Reloading nginx after changing configuration:
sudo service nginx reload //if you got no message back it means it's ok.

Let's deploy/serve apps. Installing node and pm2.

Installing node 12LTS
curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
sudo apt-get install -y nodejs

Installing pm2
sudo npm -g install pm2

Add proxy server in Nginx:

server{
 server_name example.com
 location /{
   proxy_pass http://127.0.0.1:3000 #e.g. we have a localhost server running 1t port 3000
 } 
}

Adding encryption layer

Intalling certbot
sudo snap install --classic certbot

Running certbot
sudo certbot --nginx // we have to indicate our defualt server first time only

For Renewing licencse, adding domian names, or cnames in configuration
certbot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment