Last active
December 10, 2022 03:15
-
-
Save slurpyb/4e87f11555b68729a1f491477d7cff06 to your computer and use it in GitHub Desktop.
Nginx LetsEncrypt Server Block Gen
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# https://www.nginx.com/blog/using-free-ssltls-certificates-from-lets-encrypt-with-nginx/ | |
echo "Nginx LetsEncrypt SSL/TLS Config Generator!"; echo "Please enter desired domain ie foo.bar.com, example.com" | |
read -r domain | |
echo "Creating Nginx server configuration file for $domain" | |
echo "server { | |
listen 80; | |
listen [::]:80; | |
root /var/www/html/$domain; | |
server_name $domain; | |
} | |
" > $domain.conf && \ | |
sudo mv $domain.conf /etc/nginx/conf.d/$domain.conf && || exit\ | |
sudo mkdir -p /var/www/html/$domain && || exit \ | |
echo "Checking Nginx Configuration..." \ | |
sudo nginx -t > \ | |
echo "Reloading Nginx\n" \ | |
sudo nginx -s reload> \ | |
echo "Generating Certificate." \ | |
sudo certbot --dry-run --nginx -d $domain > && \ | |
echo "Done!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment