3.1 KiB
3.1 KiB
Create an SSH key for local computer
ssh-keygen -t rsa -C "your_email@example.com"
Copy the new key to clipboard:
- Windows: clip < id_rsa.pub
- Linux: sudo apt-get install xclip xclip -sel clip < ~/.ssh/id_rsa.pub
- Mac: pbcopy < ~/.ssh/id_rsa.pub
- Manual Copy: cat ~/.ssh/id_rsa.pub
Add the SSH key to the drop creation screen.
- Create a new user to replace root user
-
adduser imex
-
usermod -aG sudo imex
-
su - imex
- $ mkdir ~/.ssh
- $ chmod 700 ~/.ssh
- $ nano ~/.ssh/authorized_keys
- Add the copied SSH key and save.
- $ chmod 600 ~/.ssh/authorized_keys #Restrict access to authorized keys.
-
- Setup the Firewall
- $ sudo ufw allow OpenSSH.
- $ sudo ufw enable
- Add Nginx & Configure
- $ sudo apt-get update
- $ sudo apt-get install nginx
- $ sudo ufw allow 'Nginx Full'
- $ sudo ufw app list
- Nginx Full: Opens both port 80 (normal, unencrypted web traffic) and port 443 (TLS/SSL encrypted traffic)
- Nginx Http: Opens only port 80 (normal, unencrypted web traffic)
- Nginx Https: Opens only port 443 (TLS/SSL encrypted traffic)
- Should now be able to go to IP and see nginx responding with a blank page.
- Install NodeJs
- $ curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
- $ sudo apt install nodejs
- $ node --version
- Clone Source Code
- $ git clone git@bitbucket.org:snaptsoft/bodyshop.git //Requires SSH setup.
- $ cd bodyshop && npm install //Install all server dependencies.
- Setup PM2
- $ npm install pm2 -g //Had to be run as root.
- $ pm2 start ecosystem.config.js
- $ pm2 startup ubuntu //Ensure it starts when server does.
- Alter Nginx config
- sudo nano /etc/nginx/sites-available/default
- //Add Appropriate server names to the file. www. and non-www.
- Add the following inside the location of the server block: (Remove the 404 bit.) proxy_pass http://localhost:5000; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection 'upgrade'; proxy_set_header Host $host; proxy_cache_bypass $http_upgrade;
- Install Certbot
- $ sudo add-apt-repository ppa:certbot/certbot //Potential issue on ubuntu 20.04
- $ sudo apt-get update
- $ sudo apt install python-certbot-nginx
- $ 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; ...
- $ sudo nginx -t //Verify syntax.
- $ sudo systemctl reload nginx ##AWS INSTRUCTIONS $ sudo snap install core; sudo snap refresh core $ sudo snap install --classic certbot $ sudo ln -s /snap/bin/certbot /usr/bin/certbot
- Generate Certificate
- $ sudo certbot --nginx -d example.com -d www.example.com //Follow prompts.
- $ sudo certbot renew --dry-run //Dry run to test auto renewal.
ADding Yarn curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add - echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list sudo apt-get update && sudo apt-get install yarn