News for hackers. Stuff that matters.
Re:Let's Encrypt and Nginx – State of the art secure web dep... by ivan_ah on Thursday March 31, 2016 @04:32PM (#11400373)
The --webroot option doesn't work for my setup, so I need to shutdown nginx for 2-3 seconds and use the --standalone option. I set this as a CRON job that will run every two months. It's not elegant, but it's done.

Here's the modified script using certonly and the --force-renew flag.

    #!/bin/bash
    # Force-renew the "Let's Encrypt" certificates for a given domain
    # Run this as root as a BI-MONTHLY cron job
    export DOMAINS="yourdomain.com,www.yourdomain.com"
    export LOGFILE="/var/log/letsencrypt/renewal_yourdomain.log"

    echo "Stopping nginx temporarily to renvew certificates for $DOMAINS ..."
    service nginx stop

    echo "Calling /opt/letsencrypt/letsencrypt-auto certonly --standalone --force-renew -d $DOMAINS"
    if ! /opt/letsencrypt/letsencrypt-auto certonly --standalone --force-renew -d $DOMAINS > $LOGFILE 2>&1 ; then
        echo "certonly call failed, restarting nginx"
        service nginx start
        echo "LOG info:"
        cat $LOGFILE
        # TODO: email administrator...
        exit 1
    fi

    echo "certonly call succeeded, restarting nginx"
    service nginx start
Note: don't run this as a daily cron job since this has --force-renew...
Re:Let's Encrypt and Nginx – State of the art secure web dep... by schoen on Thursday March 31, 2016 @04:47PM (#11400451)
Do you ever get problems with the socket still being in use after nginx is shut down?
Re:Let's Encrypt and Nginx – State of the art secure web dep... by ivan_ah on Thursday March 31, 2016 @05:13PM (#11400597)
Not on the N=1 times I've run the script, but will look out for this in the future.
Re:Let's Encrypt and Nginx – State of the art secure web dep... by ran290 on Thursday March 31, 2016 @07:24PM (#11401390)
I'm curious: why doesn't webroot work for your setup?
Re:Let's Encrypt and Nginx – State of the art secure web dep... by ivan_ah on Thursday March 31, 2016 @10:14PM (#11402095)
A dynamic script is handling all requests, so there is no "webroot" directory where you can put stuff for them to appear under /
Re:Let's Encrypt and Nginx – State of the art secure web dep... by matt4077 on Friday April 01, 2016 @01:14AM (#11402808)
You could quite easily add a location /.well-known rule to the server, right?
Re:Let's Encrypt and Nginx – State of the art secure web dep... by ivan_ah on Friday April 01, 2016 @01:15PM (#11406589)
Oh yeah, I didn't know about this option. A static dir for /.well-known is a much more elegant solution than shutting down nginx... Thx for the pointer.