Skip to content

Instantly share code, notes, and snippets.

@colinmcintosh
Created April 25, 2019 03:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save colinmcintosh/3a2d00dc0e5bb82fc3b0afc185065306 to your computer and use it in GitHub Desktop.
Save colinmcintosh/3a2d00dc0e5bb82fc3b0afc185065306 to your computer and use it in GitHub Desktop.
Configure a FreeBSD Jail for NGINX with LetsEncrypt including Auto-renewal using Cloudflare DNS
pkg install nginx
pkg update
pkg install vim py27-certbot py27-certbot-dns-cloudflare
mkdir ~/.secrets
vim ~/.secrets/cloudflare.ini
##### BEGIN INI FILE
# Cloudflare API credentials used by Certbot
dns_cloudflare_email = cloudflare-email@youremail.com
dns_cloudflare_api_key = <api key>
##### END INI FILE
chmod -R 0600 ~/.secrets
certbot certonly -a dns-cloudflare --dns-cloudflare-credentials ~/.secrets/cloudflare.ini --preferred-challenges dns-01 --server https://acme-v02.api.letsencrypt.org/directory --agree-tos --no-eff-email -m letsencrypt@example.com -d server.example.com
vim /usr/local/etc/nginx/nginx.conf
crontab -e
0 1 * * * /usr/local/bin/certbot renew --quiet --post-hook "/usr/sbin/service nginx restart"
nginx -t
service nginx restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment