Skip to content

Instantly share code, notes, and snippets.

@zubair1024
Last active April 27, 2019 15:29
Show Gist options
  • Save zubair1024/119a47aaedb4adeec85c9bb5dd330d5b to your computer and use it in GitHub Desktop.
Save zubair1024/119a47aaedb4adeec85c9bb5dd330d5b to your computer and use it in GitHub Desktop.

The workflow is as follows:

1) Install Ngnix:

sudo apt update
sudo apt install nginx

2) Ensure NGINX is running and and enabled to start automatically on reboot:

sudo systemctl start nginx
sudo systemctl enable nginx

3) Create a configuration file for the app in

/etc/nginx/conf.d/
server {
listen 80;
listen [::]:80;

server_name example.com;

location / {
proxy_pass http://localhost:3000/;
proxy_buffering off;
}
}

4) Test

sudo nginx -t

5) reload the new configuration

sudo nginx -s reload

6) Install Certificates

sudo apt-get update
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:certbot/certbot
sudo apt-get update
sudo apt-get install python-certbot-nginx
sudo certbot --nginx

7) Create Cron Job to renew them every 2 month:

0 0 1 1,3,5,7,9,11 1 certbot renew --quiet
5 0 1 1,3,5,7,9,11 1 service nginx reload
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment