Setting up node app with SSL on a DigitalOcean droplet

Written by xameeramir | Published 2017/12/24
Tech Story Tags: nodejs | digitalocean | ssl | ubuntu | linux

TLDRvia the TL;DR App

You probably Googled it it and are here! Okey, no more time waste (for MYSELF in future)…

Let’s see how to setup node app with SSL on a DigitalOcean VPS

  1. Install Heroku for it’s versioning feature
  2. Git push the app to Heroku
  3. Setup a drop let
  4. Generate SSH keys
  5. Setup git bash for SSH-ing to droplet
  6. Connect to Droplet using SSH keys
  7. Install node
  8. Confirm node installation using node -v
  9. Install MongoDB if the app needs to persist data
  10. Confirm if mongodb is running using the command sudo systemctl status mongodb
  11. Setup and configure pm2 to orchestrate the node app
  12. Confirm pm2 installation using pm2 -v
  13. Clone to a location in the server
  14. Start the node app for first cut testing
  15. Start node app as a process
  16. Install nginx
  17. Make sure that the nginx service is running using command sudo systemctl status nginx
  18. Make sure that UFW is enabled
  19. Setup nginx reverse proxy to the port on which the app is running
  20. When reverse-proxying nginx server, keep try_files $uri $uri/ =404; inside location if absolutely necessary inside /etc/nginx/sites-available/default
  21. Purchase a domain
  22. Set up SSL with Let’s Encrypt for the purchased domain
  23. Keep a backup of default nginx configuration (and all other important stuff) to revert back in case of an earthquack

Notice that we shall use services like heroku’s git feature instead of the globally famous github for version control to keep code closed source.

Originally published at xameeramir.github.io.


Published by HackerNoon on 2017/12/24