Reload nginx if certificates has been created/updated
This commit is contained in:
parent
109017566a
commit
7b40ad970f
2 changed files with 8 additions and 6 deletions
|
@ -10,6 +10,7 @@ update_certs() {
|
||||||
# Load relevant container settings
|
# Load relevant container settings
|
||||||
source "$DIR"/letsencrypt_service_data
|
source "$DIR"/letsencrypt_service_data
|
||||||
|
|
||||||
|
reload_nginx='false'
|
||||||
for cid in "${LETSENCRYPT_CONTAINERS[@]}"; do
|
for cid in "${LETSENCRYPT_CONTAINERS[@]}"; do
|
||||||
# Derive host and email variable names
|
# Derive host and email variable names
|
||||||
host_varname="LETSENCRYPT_${cid}_HOST"
|
host_varname="LETSENCRYPT_${cid}_HOST"
|
||||||
|
@ -36,14 +37,15 @@ update_certs() {
|
||||||
# Symlink to created certificate and key.
|
# Symlink to created certificate and key.
|
||||||
ln -sf ./$domain/fullchain.pem /etc/nginx/certs/$domain".crt"
|
ln -sf ./$domain/fullchain.pem /etc/nginx/certs/$domain".crt"
|
||||||
ln -sf ./$domain/key.pem /etc/nginx/certs/$domain".key"
|
ln -sf ./$domain/key.pem /etc/nginx/certs/$domain".key"
|
||||||
|
reload_nginx='true'
|
||||||
# Update certificates configuration in nginx
|
|
||||||
/usr/local/bin/docker-gen -only-exposed /app/nginx.tmpl /etc/nginx/conf.d/default.conf
|
|
||||||
nginx -s reload
|
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
unset LETSENCRYPT_CONTAINERS
|
unset LETSENCRYPT_CONTAINERS
|
||||||
|
if [[ "$reload_nginx" == 'true' ]]; then
|
||||||
|
/usr/local/bin/docker-gen -only-exposed /app/nginx.tmpl /etc/nginx/conf.d/default.conf
|
||||||
|
nginx -s reload
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
pid=
|
pid=
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
nginx -s reload
|
||||||
|
|
||||||
docker-gen \
|
docker-gen \
|
||||||
-only-exposed \
|
-only-exposed \
|
||||||
-notify '/app/update_certs' \
|
-notify '/app/update_certs' \
|
||||||
/app/letsencrypt_service_data.tmpl /app/letsencrypt_service_data
|
/app/letsencrypt_service_data.tmpl /app/letsencrypt_service_data
|
||||||
|
|
||||||
nginx -s reload
|
|
||||||
|
|
Loading…
Reference in a new issue