Skip to content

Instantly share code, notes, and snippets.

@maxkagamine
Last active March 9, 2024 09:01
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save maxkagamine/5b6c34db6045d6413db3b333d6d2bae2 to your computer and use it in GitHub Desktop.
Save maxkagamine/5b6c34db6045d6413db3b333d6d2bae2 to your computer and use it in GitHub Desktop.
Guide to running an nginx reverse proxy on Unraid with a Let's Encrypt wildcard cert, using the official nginx and certbot Docker images.
#!/bin/bash
#description=Updates the web gui ssl cert if it's been renewed.
set -eo pipefail
CERTS_DIR=/mnt/user/appdata/nginx-certbot/certs/live/default
BUNDLE=/boot/config/ssl/certs/certificate_bundle.pem
new_bundle=$(cat \
"$CERTS_DIR/cert.pem" \
"$CERTS_DIR/fullchain.pem" \
"$CERTS_DIR/privkey.pem")
[[ -f $BUNDLE ]] && old_bundle=$(cat "$BUNDLE")
if [[ "$old_bundle" != "$new_bundle" ]]; then
echo 'Updating SSL cert'
cat <<<"$new_bundle" >"$BUNDLE"
/etc/rc.d/rc.nginx restart
else
echo 'Nothing to do'
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment