Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: '3'

services:
nginx:
image: nginx:1.15-alpine
image: nginx:1.30-alpine
restart: unless-stopped
volumes:
- ./data/nginx:/etc/nginx/conf.d
Expand Down
23 changes: 13 additions & 10 deletions init-letsencrypt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@ data_path="./data/certbot"
email="" # Adding a valid address is strongly recommended
staging=0 # Set to 1 if you're testing your setup to avoid hitting request limits

if [ -d "$data_path" ]; then
read -p "Existing data found for $domains. Continue and replace existing certificate? (y/N) " decision
# Use the first domain as the certificate directory name
cert_dir="${domains[0]}"

if [ -d "$data_path/conf/live/$cert_dir" ]; then
read -p "Existing data found for $cert_dir (${domains[*]}). Continue and replace existing certificate? (y/N) " decision
if [ "$decision" != "Y" ] && [ "$decision" != "y" ]; then
exit
fi
Expand All @@ -27,9 +30,9 @@ if [ ! -e "$data_path/conf/options-ssl-nginx.conf" ] || [ ! -e "$data_path/conf/
echo
fi

echo "### Creating dummy certificate for $domains ..."
path="/etc/letsencrypt/live/$domains"
mkdir -p "$data_path/conf/live/$domains"
echo "### Creating dummy certificate for $cert_dir (${domains[*]}) ..."
path="/etc/letsencrypt/live/$cert_dir"
mkdir -p "$data_path/conf/live/$cert_dir"
docker-compose run --rm --entrypoint "\
openssl req -x509 -nodes -newkey rsa:$rsa_key_size -days 1\
-keyout '$path/privkey.pem' \
Expand All @@ -42,15 +45,15 @@ echo "### Starting nginx ..."
docker-compose up --force-recreate -d nginx
echo

echo "### Deleting dummy certificate for $domains ..."
echo "### Deleting dummy certificate for $cert_dir ..."
docker-compose run --rm --entrypoint "\
rm -Rf /etc/letsencrypt/live/$domains && \
rm -Rf /etc/letsencrypt/archive/$domains && \
rm -Rf /etc/letsencrypt/renewal/$domains.conf" certbot
rm -Rf /etc/letsencrypt/live/$cert_dir && \
rm -Rf /etc/letsencrypt/archive/$cert_dir && \
rm -Rf /etc/letsencrypt/renewal/${cert_dir}.conf" certbot
echo


echo "### Requesting Let's Encrypt certificate for $domains ..."
echo "### Requesting Let's Encrypt certificate for ${domains[*]} ..."
#Join $domains to -d args
domain_args=""
for domain in "${domains[@]}"; do
Expand Down