diff --git a/app/entrypoint.sh b/app/entrypoint.sh index a98d7aba..dec098c5 100755 --- a/app/entrypoint.sh +++ b/app/entrypoint.sh @@ -45,6 +45,19 @@ function get_nginx_proxy_cid { fi } +function get_nginx_gen_cid { + # Check if any container has been labelled as the nginx gen container. + local labeled_cid=$(docker_api "/containers/json" | jq -r '.[] | select( .Labels["com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_gen"] == "true")|.Id') + if [[ ! -z "${labeled_cid:-}" ]]; then + export NGINX_DOCKER_GEN_CONTAINER=$labeled_cid + fi + if [[ -z "${NGINX_DOCKER_GEN_CONTAINER:-}" ]]; then + echo "Error: can't get nginx-gen container id !" >&2 + echo "Label the nginx gen container to use with 'com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_gen=true'." >&2 + exit 1 + fi +} + function check_writable_directory { local dir="$1" docker_api "/containers/$HOSTNAME/json" | jq ".Mounts[].Destination" | grep -q "^\"$dir\"$" @@ -79,6 +92,7 @@ source /app/functions.sh if [[ "$*" == "/bin/bash /app/start.sh" ]]; then check_docker_socket + get_nginx_gen_cid if [[ -z "${NGINX_DOCKER_GEN_CONTAINER:-}" ]]; then [[ -z "${NGINX_PROXY_CONTAINER:-}" ]] && get_nginx_proxy_cid fi diff --git a/app/nginx_location.conf b/app/nginx_location.conf index f33c3d59..0d4399da 100644 --- a/app/nginx_location.conf +++ b/app/nginx_location.conf @@ -1,4 +1,5 @@ -location ^~ /.well-known/acme-challenge/ { +location ~ /.well-known { + # autoindex on; allow all; root /usr/share/nginx/html; try_files $uri =404;