diff --git a/Dockerfile b/Dockerfile index e1c997fa..e515d826 100644 --- a/Dockerfile +++ b/Dockerfile @@ -62,8 +62,8 @@ SHELL ["/bin/ash", "-eo", "pipefail", "-c"] ARG CRS_VER=v4.1.0 COPY rootfs / -COPY --from=zoeyvid/certbot-docker:26 /usr/local /usr/local -COPY --from=zoeyvid/curl-quic:375 /usr/local/bin/curl /usr/local/bin/curl +COPY --from=zoeyvid/certbot-docker:27 /usr/local /usr/local +COPY --from=zoeyvid/curl-quic:376 /usr/local/bin/curl /usr/local/bin/curl RUN apk upgrade --no-cache -a && \ apk add --no-cache ca-certificates tzdata tini \ @@ -127,6 +127,7 @@ ENV PUID=0 \ DISABLE_H3_QUIC=false \ NGINX_ACCESS_LOG=false \ NGINX_LOG_NOT_FOUND=false \ + NGINX_404_REDIRECT=true \ NGINX_DISABLE_PROXY_BUFFERING=false \ CLEAN=true \ FULLCLEAN=false \ diff --git a/compose.yaml b/compose.yaml index 5cc1d5f5..cb8b32ed 100644 --- a/compose.yaml +++ b/compose.yaml @@ -31,7 +31,8 @@ services: # - "DISABLE_HTTP=true" # disables nginx to listen on port 80, default false # - "DISABLE_H3_QUIC=true" # disables nginx to listen on port 443 udp for default and your hosts, this will disable HTTP/3 and QUIC, default false # - "NGINX_LOG_NOT_FOUND=true" # Allow logging of 404 errors, default false -# - "NGINX_DISABLE_PROXY_BUFFERING=true" # Disabled the proxy-buffering option of nginx, default false +# - "NGINX_404_REDIRECT=false" # Redirect to / instead of showing a 404 error page, default true +# - "NGINX_DISABLE_PROXY_BUFFERING=true" # Disables the proxy-buffering option of nginx, default false # - "CLEAN=false" # Clean folders, default true # - "FULLCLEAN=true" # Clean unused config folders, default false # - "SKIP_IP_RANGES=true" # Skip feteching/whitelisting ip ranges from aws and cloudflare, default false diff --git a/rootfs/usr/local/bin/start.sh b/rootfs/usr/local/bin/start.sh index 36766328..8c5dcb82 100755 --- a/rootfs/usr/local/bin/start.sh +++ b/rootfs/usr/local/bin/start.sh @@ -30,9 +30,14 @@ if [ -n "$NPM_CERT_ID" ] && [ -z "$DEFAULT_CERT_ID" ]; then export DEFAULT_CERT_ID="$NPM_CERT_ID" fi +if [ -n "$NPM_CERT_ID" ] && [ -n "$DEFAULT_CERT_ID" ]; then + echo "You've set DEFAULT_CERT_ID, but didn't removed NPM_CERT_ID, please remove it." + sleep inf +fi -if [ -z "$TZ" ] || ! echo "$TZ" | grep -q "^[A-Za-z0-9/_+-]\+$"; then - echo "TZ is unset or invalid, it can consist of lower and upper letters a-z A-Z, numbers 0-9, slashes, underscores, plus and minus signs." + +if [ -z "$TZ" ] || ! echo "$TZ" | grep -q "^[A-Za-z0-9_+-]\+/[A-Za-z0-9_+-]\+$"; then + echo "TZ is unset or invalid, it can consist of lower and upper letters a-z A-Z, numbers 0-9, underscores, plus and minus signs which are split by a slash." sleep inf fi @@ -141,6 +146,11 @@ if ! echo "$NGINX_LOG_NOT_FOUND" | grep -q "^true$\|^false$"; then sleep inf fi +if ! echo "$NGINX_404_REDIRECT" | grep -q "^true$\|^false$"; then + echo "NGINX_404_REDIRECT needs to be true or false." + sleep inf +fi + if ! echo "$NGINX_DISABLE_PROXY_BUFFERING" | grep -q "^true$\|^false$"; then echo "NGINX_DISABLE_PROXY_BUFFERING needs to be true or false." sleep inf @@ -806,6 +816,12 @@ else sed -i "s|log_not_found.*|log_not_found off;|g" /usr/local/nginx/conf/nginx.conf fi +if [ "$NGINX_404_REDIRECT" = "true" ]; then + sed -i "s|#error_page 404|error_page 404|g" /usr/local/nginx/conf/nginx.conf +else + sed -i "s|error_page 404|#error_page 404|g" /usr/local/nginx/conf/nginx.conf +fi + if [ "$NGINX_DISABLE_PROXY_BUFFERING" = "true" ]; then sed -i "s|proxy_buffering.*|proxy_buffering off;|g" /usr/local/nginx/conf/nginx.conf else