Skip to content

Instantly share code, notes, and snippets.

@sajanv88
Created May 27, 2023 05:34
Show Gist options
  • Save sajanv88/ba0e42d3ecd260dc5b5da6772acb7dd1 to your computer and use it in GitHub Desktop.
Save sajanv88/ba0e42d3ecd260dc5b5da6772acb7dd1 to your computer and use it in GitHub Desktop.
Generate ssl certificates for nginx server
# BEFORE YOU RUN THE SCRIPT MAKE SURE YOU DO THE FOLLOWING:
# check if you have site folder enabled.
# cd /etc/nginx/sites-available/$DOMAIN_NAME
# If it is enabled then open it in a editor
# sudo vim /etc/nginx/sites-available/$DOMAIN_NAME
# then look for
# server_name $DOMAIN_NAME www.$DOMAIN_NAME;
# If not then add it and save it.
DOMAIN_NAME=yourdomainname.com
sudo apt install certbot python3-certbot-nginx
sudo nginx -t
sudo systemctl reload nginx
sudo ufw status
sudo ufw allow 'Nginx Full'
sudo ufw delete allow 'Nginx HTTP'
sudo ufw status
sudo certbot --nginx -d $DOMAIN_NAME -d www.$DOMAIN_NAME
# check the periodic run
sudo systemctl status certbot.timer
# test dry run
sudo certbot renew --dry-run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment