diff --git a/Dockerfile b/Dockerfile index 96b4bada..9b89da41 100644 --- a/Dockerfile +++ b/Dockerfile @@ -57,4 +57,4 @@ ENV NODE_ENV=production \ WORKDIR /app ENTRYPOINT ["start.sh"] -HEALTHCHECK CMD check-health.sh +HEALTHCHECK CMD healthcheck.sh diff --git a/README.md b/README.md index 7982a566..0a1ad2a4 100644 --- a/README.md +++ b/README.md @@ -153,6 +153,7 @@ services: # - "NPM_DISABLE_IPV6=true" # disable IPv6 for the NPM backend, incompatible with NPM_IPV6_BINDING, default false # - "NPM_LISTEN_LOCALHOST=true" # Bind the NPM Dashboard on Port 81 only to localhost, incompatible with NPM_IPV4_BINDING/NPM_IPV6_BINDING/NPM_DISABLE_IPV6, default false # - "NPM_CERT_ID=1" # ID of cert, which should be used instead of dummycerts, default unset/dummycerts +# - "DISABLE_HTTP=true" # disables nginx to listen on port 80, default false # - "NGINX_LOG_NOT_FOUND=true" # Allow logging of 404 errors, default false # - "CLEAN=false" # Clean folders, default true # - "FULLCLEAN=true" # Clean unused config folders, default false diff --git a/compose.yaml b/compose.yaml index 45249bcd..d2bb9260 100644 --- a/compose.yaml +++ b/compose.yaml @@ -23,6 +23,7 @@ services: # - "NPM_DISABLE_IPV6=true" # disable IPv6 for the NPM backend, incompatible with NPM_IPV6_BINDING, default false # - "NPM_LISTEN_LOCALHOST=true" # Bind the NPM Dashboard on Port 81 only to localhost, incompatible with NPM_IPV4_BINDING/NPM_IPV6_BINDING/NPM_DISABLE_IPV6, default false # - "NPM_CERT_ID=1" # ID of cert, which should be used instead of dummycerts, default unset/dummycerts +# - "DISABLE_HTTP=true" # disables nginx to listen on port 80, default false # - "NGINX_LOG_NOT_FOUND=true" # Allow logging of 404 errors, default false # - "CLEAN=false" # Clean folders, default true # - "FULLCLEAN=true" # Clean unused config folders, default false diff --git a/rootfs/bin/check-health.sh b/rootfs/bin/check-health.sh deleted file mode 100755 index e337cede..00000000 --- a/rootfs/bin/check-health.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh - -if (if [ "$PHP81" = true ]; then cgi-fcgi -bind -connect /dev/php81.sock > /dev/null 2>&1; fi && if [ "$PHP82" = true ]; then cgi-fcgi -bind -connect /dev/php82.sock > /dev/null 2>&1; fi && [ "$(curl -sk https://127.0.0.1:81/api/ | jq --raw-output .status)" = "OK" ]); then - echo "OK" - exit 0 -else - echo "NOT OK" - exit 1 -fi diff --git a/rootfs/bin/healthcheck.sh b/rootfs/bin/healthcheck.sh new file mode 100755 index 00000000..9b9ad097 --- /dev/null +++ b/rootfs/bin/healthcheck.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +export HC_IP="localhost" + +if [ "$NPM_LISTEN_LOCALHOST" = "true" ]; then + export NPM_IPV4_BINDING="127.0.0.1" + export NPM_IPV6_BINDING="[::1]" +fi + +if [ -n "$NPM_IPV6_BINDING" ]; then + export HC_IP="$NPM_IPV6_BINDING" +elif [ -n "$NPM_IPV4_BINDING" ]; then + export HC_IP="$NPM_IPV4_BINDING" +fi + +if (if [ "$PHP81" = true ]; then cgi-fcgi -bind -connect /dev/php81.sock > /dev/null 2>&1; fi && if [ "$PHP82" = true ]; then cgi-fcgi -bind -connect /dev/php82.sock > /dev/null 2>&1; fi && [ "$(curl -sk https://"$HC_IP":81/api/ | jq --raw-output .status)" = "OK" ]); then + echo "OK" + exit 0 +else + echo "NOT OK" + exit 1 +fi diff --git a/rootfs/bin/start.sh b/rootfs/bin/start.sh index 5d45bc05..bba20465 100755 --- a/rootfs/bin/start.sh +++ b/rootfs/bin/start.sh @@ -495,6 +495,16 @@ else sed -i "s/#\?listen \[\([0-9a-f:]\+\)\]:\(bep\)/listen \[::\]:$NPM_PORT/g" /usr/local/nginx/conf/conf.d/npm-no-server-name.conf fi +if [ "$DISABLE_HTTP" = "true" ]; then + find /data/nginx -type f -name '*.conf' -exec sed -i "s|#\?\(listen.*80\)|#\1|g" {} \; + find /app/templates -type f -name '*.conf' -exec sed -i "s|#\?\(listen.*80\)|#\1|g" {} \; + find /usr/local/nginx/conf/conf.d -type f -name '*.conf' -exec sed -i "s|#\?\(listen.*80\)|#\1|g" {} \; +else + find /data/nginx -type f -name '*.conf' -exec sed -i "s|#\?\(listen.*80\)|\1|g" {} \; + find /app/templates -type f -name '*.conf' -exec sed -i "s|#\?\(listen.*80\)|\1|g" {} \; + find /usr/local/nginx/conf/conf.d -type f -name '*.conf' -exec sed -i "s|#\?\(listen.*80\)|\1|g" {} \; +fi + if [ "$NGINX_LOG_NOT_FOUND" = "true" ]; then sed -i "s|log_not_found off;|log_not_found on;|g" /usr/local/nginx/conf/nginx.conf fi