Skip to content

Commit 8ebf110

Browse files
authored
Merge pull request #1160 from nginx-proxy/dot-not-enforce-html-dir
fix: stop enforcing html directory
2 parents 3cb7df6 + 2c1b9a4 commit 8ebf110

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

app/entrypoint.sh

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function check_docker_socket {
2727
fi
2828
}
2929

30-
function check_writable_directory {
30+
function check_dir_is_mounted_volume {
3131
local dir="$1"
3232
if [[ $(get_self_cid) ]]; then
3333
if ! docker_api "/containers/$(get_self_cid)/json" | jq ".Mounts[].Destination" | grep -q "^\"$dir\"$"; then
@@ -36,6 +36,13 @@ function check_writable_directory {
3636
else
3737
echo "Warning: can't check if '$dir' is a mounted volume without self container ID."
3838
fi
39+
}
40+
41+
function check_writable_directory {
42+
local dir="$1"
43+
44+
check_dir_is_mounted_volume "$dir"
45+
3946
if [[ ! -d "$dir" ]]; then
4047
echo "Error: can't access to '$dir' directory !" >&2
4148
echo "Check that '$dir' directory is declared as a writable volume." >&2
@@ -49,6 +56,18 @@ function check_writable_directory {
4956
rm -f "$dir/.check_writable"
5057
}
5158

59+
function warn_html_directory {
60+
local dir='/usr/share/nginx/html'
61+
62+
check_dir_is_mounted_volume "$dir"
63+
64+
if [[ ! -d "$dir" ]] || ! touch "$dir/.check_writable" 2>/dev/null; then
65+
echo "Warning: can't access or write to '$dir' directory. This will prevent HTML-01 challenges from working correctly."
66+
echo "If you are only using DNS-01 challenges, you can ignore this warning, otherwise check that '$dir' is declared as a writable volume."
67+
fi
68+
rm -f "$dir/.check_writable"
69+
}
70+
5271
function check_dh_group {
5372
# DH params will be supplied for acme-companion here:
5473
local DHPARAM_FILE='/etc/nginx/certs/dhparam.pem'
@@ -176,7 +195,7 @@ if [[ "$*" == "/bin/bash /app/start.sh" ]]; then
176195
check_writable_directory '/etc/nginx/certs'
177196
parse_true "${ACME_HTTP_CHALLENGE_LOCATION:=false}" && check_writable_directory '/etc/nginx/vhost.d'
178197
check_writable_directory '/etc/acme.sh'
179-
check_writable_directory '/usr/share/nginx/html'
198+
warn_html_directory
180199
if [[ -f /app/letsencrypt_user_data ]]; then
181200
check_writable_directory '/etc/nginx/vhost.d'
182201
check_writable_directory '/etc/nginx/conf.d'

0 commit comments

Comments
 (0)