Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: stop enforcing html directory #1160

Merged
merged 1 commit into from
Oct 28, 2024
Merged
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
23 changes: 21 additions & 2 deletions app/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function check_docker_socket {
fi
}

function check_writable_directory {
function check_dir_is_mounted_volume {
local dir="$1"
if [[ $(get_self_cid) ]]; then
if ! docker_api "/containers/$(get_self_cid)/json" | jq ".Mounts[].Destination" | grep -q "^\"$dir\"$"; then
Expand All @@ -36,6 +36,13 @@ function check_writable_directory {
else
echo "Warning: can't check if '$dir' is a mounted volume without self container ID."
fi
}

function check_writable_directory {
local dir="$1"

check_dir_is_mounted_volume "$dir"

if [[ ! -d "$dir" ]]; then
echo "Error: can't access to '$dir' directory !" >&2
echo "Check that '$dir' directory is declared as a writable volume." >&2
Expand All @@ -49,6 +56,18 @@ function check_writable_directory {
rm -f "$dir/.check_writable"
}

function warn_html_directory {
local dir='/usr/share/nginx/html'

check_dir_is_mounted_volume "$dir"

if [[ ! -d "$dir" ]] || ! touch "$dir/.check_writable" 2>/dev/null; then
echo "Warning: can't access or write to '$dir' directory. This will prevent HTML-01 challenges from working correctly."
echo "If you are only using DNS-01 challenges, you can ignore this warning, otherwise check that '$dir' is declared as a writable volume."
fi
rm -f "$dir/.check_writable"
}

function check_dh_group {
# DH params will be supplied for acme-companion here:
local DHPARAM_FILE='/etc/nginx/certs/dhparam.pem'
Expand Down Expand Up @@ -176,7 +195,7 @@ if [[ "$*" == "/bin/bash /app/start.sh" ]]; then
check_writable_directory '/etc/nginx/certs'
parse_true "${ACME_HTTP_CHALLENGE_LOCATION:=false}" && check_writable_directory '/etc/nginx/vhost.d'
check_writable_directory '/etc/acme.sh'
check_writable_directory '/usr/share/nginx/html'
warn_html_directory
if [[ -f /app/letsencrypt_user_data ]]; then
check_writable_directory '/etc/nginx/vhost.d'
check_writable_directory '/etc/nginx/conf.d'
Expand Down