Skip to content

Commit 4dab61d

Browse files
committedMar 11, 2025··
fix start if the fancyindex module is not loaded/also include stdout in error output of execFile
Signed-off-by: Zoey <zoey@z0ey.de>
1 parent 00b042a commit 4dab61d

File tree

8 files changed

+64
-65
lines changed

8 files changed

+64
-65
lines changed
 

‎Dockerfile

+20-11
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,25 @@ COPY darkmode.css /app/dist/css/darkmode.css
1313
COPY security.txt /app/dist/.well-known/security.txt
1414

1515

16-
FROM alpine:3.21.3 AS backend
16+
FROM --platform="$BUILDPLATFORM" alpine:3.21.3 AS build-backend
1717
SHELL ["/bin/ash", "-eo", "pipefail", "-c"]
18-
ARG NODE_ENV=production
18+
ARG NODE_ENV=production \
19+
TARGETARCH
1920
COPY backend /app
2021
COPY global/certbot-dns-plugins.json /app/certbot-dns-plugins.json
2122
WORKDIR /app
2223
RUN apk upgrade --no-cache -a && \
23-
apk add --no-cache ca-certificates nodejs yarn npm python3 build-base binutils file && \
24+
apk add --no-cache ca-certificates nodejs yarn file && \
2425
yarn global add clean-modules && \
25-
yarn install && \
26-
yarn cache clean --all && \
27-
clean-modules --yes && \
26+
if [ "$TARGETARCH" = "amd64" ]; then npm_config_arch=x64 npm_config_target_arch=x64 yarn install; \
27+
elif [ "$TARGETARCH" = "arm64" ]; then npm_config_arch=arm64 npm_config_target_arch=arm64 yarn install; \
28+
else yarn install; fi && \
29+
yarn cache clean && \
30+
clean-modules --yes
31+
FROM alpine:3.21.3 AS strip-backend
32+
COPY --from=build-backend /app /app
33+
RUN apk upgrade --no-cache -a && \
34+
apk add --no-cache ca-certificates binutils file && \
2835
find /app/node_modules -name "*.node" -type f -exec strip -s {} \; && \
2936
find /app/node_modules -name "*.node" -type f -exec file {} \;
3037

@@ -58,11 +65,11 @@ FROM zoeyvid/nginx-quic:450-python
5865
SHELL ["/bin/ash", "-eo", "pipefail", "-c"]
5966
ENV NODE_ENV=production
6067
ARG CRS_VER=v4.12.0
61-
COPY rootfs /
6268

63-
COPY --from=frontend /app/dist /html/frontend
64-
COPY --from=backend /app /app
69+
COPY rootfs /
70+
COPY --from=strip-backend /app /app
6571
WORKDIR /app
72+
6673
RUN apk upgrade --no-cache -a && \
6774
apk add --no-cache ca-certificates tzdata tini curl util-linux-misc \
6875
nodejs \
@@ -81,17 +88,19 @@ RUN apk upgrade --no-cache -a && \
8188
mv -v /tmp/coreruleset/crs-setup.conf.example /usr/local/nginx/conf/conf.d/include/coreruleset/crs-setup.conf.example && \
8289
mv -v /tmp/coreruleset/plugins /usr/local/nginx/conf/conf.d/include/coreruleset/plugins && \
8390
mv -v /tmp/coreruleset/rules /usr/local/nginx/conf/conf.d/include/coreruleset/rules && \
84-
rm -r /tmp/* && \
8591
luarocks-5.1 install lua-cjson && \
8692
luarocks-5.1 install lua-resty-http && \
8793
luarocks-5.1 install lua-resty-string && \
8894
luarocks-5.1 install lua-resty-openssl && \
8995
yarn global add nginxbeautifier && \
96+
yarn cache clean && \
9097
apk del --no-cache luarocks5.1 lua5.1-dev lua5.1-sec build-base git yarn && \
9198
ln -s /app/password-reset.js /usr/local/bin/password-reset.js && \
9299
ln -s /app/sqlite-vaccum.js /usr/local/bin/sqlite-vaccum.js && \
93-
ln -s /app/index.js /usr/local/bin/index.js
100+
ln -s /app/index.js /usr/local/bin/index.js && \
101+
rm -r /tmp/*
94102

103+
COPY --from=frontend /app/dist /html/frontend
95104
COPY --from=crowdsec /src/crowdsec-nginx-bouncer/nginx/crowdsec_nginx.conf /usr/local/nginx/conf/conf.d/include/crowdsec_nginx.conf
96105
COPY --from=crowdsec /src/crowdsec-nginx-bouncer/lua-mod/config_example.conf /usr/local/nginx/conf/conf.d/include/crowdsec.conf
97106
COPY --from=crowdsec /src/crowdsec-nginx-bouncer/lua-mod/templates/captcha.html /usr/local/nginx/conf/conf.d/include/captcha.html

‎README.md

+2-4
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,7 @@ a) Custom Nginx Configuration (advanced tab), which looks the following for file
159159
location / {
160160
include conf.d/include/always.conf;
161161
alias /var/www/<your-html-site-folder-name>/;
162-
fancyindex off; # alternative to nginxs "index" option (looks better and has more options), please load the module first in the compsoe.yaml
163-
}
162+
fancyindex off; # alternative to nginxs "index" option (looks better and has more options), please load the module first in the compose.yaml
164163
```
165164
b) Custom Nginx Configuration (advanced tab), which looks the following for file server and **php**:
166165
- Note: the slash at the end of the file path is important
@@ -171,8 +170,7 @@ b) Custom Nginx Configuration (advanced tab), which looks the following for file
171170
location / {
172171
include conf.d/include/always.conf;
173172
alias /var/www/<your-html-site-folder-name>/;
174-
fancyindex off; # alternative to nginxs "index" option (looks better and has more options), please load the module first in the compsoe.yaml
175-
173+
fancyindex off; # alternative to nginxs "index" option (looks better and has more options), please load the module first in the compose.yaml
176174
location ~ [^/]\.php(/|$) {
177175
fastcgi_pass php82;
178176
fastcgi_split_path_info ^(.+?\.php)(/.*)$;

‎backend/lib/utils.js

+6-11
Original file line numberDiff line numberDiff line change
@@ -26,22 +26,17 @@ module.exports = {
2626
* @param {String} cmd
2727
* @param {Array} args
2828
*/
29-
execFile: async function (cmd, args, options = {}) {
29+
execFile: function (cmd, args) {
3030
logger.debug('CMD: ' + cmd + ' ' + (args ? args.join(' ') : ''));
31-
const { stdout, stderr } = await new Promise((resolve, reject) => {
32-
const child = execFile(cmd, args, options, (isError, stdout, stderr) => {
33-
if (isError) {
34-
reject(new error.CommandError(stderr, isError));
31+
return new Promise((resolve, reject) => {
32+
execFile(cmd, args, (err, stdout, stderr) => {
33+
if (err) {
34+
reject(new error.CommandError((stdout + stderr).trim(), err));
3535
} else {
36-
resolve({ stdout, stderr });
36+
resolve((stdout + stderr).trim());
3737
}
3838
});
39-
40-
child.on('error', (e) => {
41-
reject(new error.CommandError(stderr, 1, e));
42-
});
4339
});
44-
return stdout;
4540
},
4641

4742
/**

‎rootfs/usr/local/bin/aio.sh

+9-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,14 @@
33
if [ "$NC_AIO" = "true" ] && [ ! -f /data/aio.lock ]; then
44
while [ "$(healthcheck.sh)" != "OK" ]; do sleep 10s; done
55
# shellcheck disable=SC2016
6-
curl -POST http://127.0.0.1:"$NIBEP"/nginx/proxy-hosts -sH 'Content-Type: application/json' -d '{"domain_names":["'"$NC_DOMAIN"'"],"forward_scheme":"http","forward_host":"127.0.0.1","forward_port":11000,"access_list_id":"0","certificate_id":"new","meta":{"letsencrypt_email":"","letsencrypt_agree":true,"dns_challenge":false},"advanced_config":"","locations":[{"path":"/","advanced_config":"proxy_set_header Accept-Encoding $http_accept_encoding;","forward_scheme":"http","forward_host":"127.0.0.1","forward_port":11000}],"block_exploits":false,"caching_enabled":false,"allow_websocket_upgrade":true,"http2_support":true,"hsts_enabled":true,"hsts_subdomains":true,"ssl_forced":true}' -H "Authorization: Bearer $(curl -POST http://127.0.0.1:"$NIBEP"/tokens -sH 'Content-Type: application/json' -d '{"identity":"'"$INITIAL_ADMIN_EMAIL"'"],"secret":"'"$INITIAL_ADMIN_PASSWORD"'"]}' | jq -r .token)"
6+
if ! curl -POST http://127.0.0.1:"$NIBEP"/nginx/proxy-hosts -sSH 'Content-Type: application/json' -d '{"domain_names":["'"$NC_DOMAIN"'"],"forward_scheme":"http","forward_host":"127.0.0.1","forward_port":11000,"allow_websocket_upgrade":true,"access_list_id":"0","certificate_id":"new","ssl_forced":true,"http2_support":true,"hsts_enabled":true,"hsts_subdomains":true,"meta":{"letsencrypt_email":"","letsencrypt_agree":true,"dns_challenge":false},"advanced_config":"","locations":[{"path":"/","advanced_config":"proxy_set_header Accept-Encoding $http_accept_encoding;","forward_scheme":"http","forward_host":"127.0.0.1","forward_port":11000}],"block_exploits":false,"caching_enabled":false}' -H "Authorization: Bearer $(curl -POST http://127.0.0.1:"$NIBEP"/tokens -sSH 'Content-Type: application/json' -d '{"identity":"'"$INITIAL_ADMIN_EMAIL"'","secret":"'"$INITIAL_ADMIN_PASSWORD"'"}' | jq -r .token)" > /dev/null 2>&1; then
7+
echo
8+
echo "The default config for AIO should now be created."
9+
echo
10+
else
11+
echo
12+
echo "There was an error creating the TLS certificate for AIO. Please try to create the cert yourself in the NPMplus UI and update the AIO proxy host to use this cert, see the NPMplus config in the AIO reverse proxy guide as an example for the TLS tab."
13+
echo
14+
fi
715
touch /data/aio.lock
8-
echo "The default config for AIO should now be created. Please check the log for any errors and try to resolve them, then delete the aio.lock file and retry."
916
fi

‎rootfs/usr/local/bin/launch.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Group ID: $(id -g)
1010
-------------------------------------
1111
"
1212

13-
if [ -z "$(find /data/tls/certbot/accounts/"$(echo "$ACME_SERVER" | sed "s|^https\?://\([^/]\+\).*$|\1|g")" -type f)" ]; then
13+
if [ -z "$(find /data/tls/certbot/accounts/"$(echo "$ACME_SERVER" | sed "s|^https\?://\([^/]\+\).*$|\1|g")" -type f 2> /dev/null)" ]; then
1414
if [ "$(echo "$ACME_SERVER" | sed "s|^https\?://\([^/]\+\).*$|\1|g")" = "acme.zerossl.com" ] && [ -z "$ACME_EAB_KID" ] && [ -z "$ACME_EAB_HMAC_KEY" ]; then
1515
if [ -z "$ACME_EMAIL" ]; then
1616
echo "ACME_EMAIL is required to use zerossl. Either set it or use a different acme server like letsencrypt (ACME_SERVER: https://acme-v02.api.letsencrypt.org/directory)"

‎rootfs/usr/local/bin/start.sh

+11-15
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ if [ -n "$NC_AIO" ] && ! echo "$NC_AIO" | grep -q "^true$\|^false$"; then
4444
sleep inf
4545
fi
4646
if [ "$NC_AIO" = "true" ]; then
47-
if [ -z "$NC_DOMAIN" ]; then
48-
echo "NC_DOMAIN is required in AIO mode."
47+
if [ -z "$NC_DOMAIN" ] || ! echo "$NC_DOMAIN" | grep -q "\."; then
48+
echo "NC_DOMAIN is unset (but required in AIO mode) or invalid, it needs to contain a dot."
4949
sleep inf
5050
fi
5151
export DISABLE_HTTP="${DISABLE_HTTP:-true}"
@@ -138,18 +138,18 @@ if [ -n "$DEBUG" ]; then
138138
fi
139139

140140

141-
if [ -z "$TZ" ] || ! echo "$TZ" | grep -q "^[A-Za-z0-9_+-]\+/[A-Za-z0-9_+-]\+$"; then
142-
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."
141+
if [ -z "$TZ" ] || [ ! -s /usr/share/zoneinfo/"$TZ" ]; then
142+
echo "TZ is unset or invalid."
143143
sleep inf
144144
fi
145145

146146

147-
if ! echo "$ACME_SERVER" | grep -q "^https\?://.\+$"; then
147+
if ! echo "$ACME_SERVER" | grep -q "^https\?://"; then
148148
echo "ACME_SERVER needs to start with http:// or https://"
149149
sleep inf
150150
fi
151151

152-
if [ -n "$ACME_EMAIL" ] && ! echo "$ACME_EMAIL" | grep -q "^.*@.*$"; then
152+
if [ -n "$ACME_EMAIL" ] && ! echo "$ACME_EMAIL" | grep -q "@"; then
153153
echo "ACME_EMAIL needs to contains @."
154154
sleep inf
155155
fi
@@ -956,6 +956,8 @@ if [ "$NGINX_LOAD_OPENTELEMETRY_MODULE" = "true" ]; then
956956
fi
957957
if [ "$NGINX_LOAD_FANCYINDEX_MODULE" = "true" ]; then
958958
sed -i "s|#\(load_module.\+ngx_http_fancyindex_module.so;\)|\1|g" /usr/local/nginx/conf/nginx.conf
959+
sed -i "s|#fancyindex|fancyindex|g" /usr/local/nginx/conf/nginx.conf
960+
sed -i "s|#fancyindex|fancyindex|g" /usr/local/nginx/conf/conf.d/include/always.conf
959961
fi
960962
if [ "$NGINX_LOAD_GEOIP2_MODULE" = "true" ]; then
961963
sed -i "s|#\(load_module.\+geoip2_module.so;\)|\1|g" /usr/local/nginx/conf/nginx.conf
@@ -1022,13 +1024,13 @@ if [ "$PUID" != "0" ]; then
10221024
echo "ERROR: Unable to set group against the user properly"
10231025
sleep inf
10241026
fi
1025-
find /proc/self/fd \
1026-
/usr/local \
1027+
find /usr/local \
10271028
/data \
10281029
/run \
10291030
/tmp \
10301031
-not \( -uid "$PUID" -and -gid "$PGID" \) \
10311032
-exec chown "$PUID:$PGID" {} \;
1033+
chown "$PUID:$PGID" /proc/self/fd/2
10321034
if [ "$PHP82" = "true" ]; then
10331035
sed -i "s|;\?user =.*|;user = root|" /data/php/82/php-fpm.d/www.conf
10341036
sed -i "s|;\?group =.*|;group = root|" /data/php/82/php-fpm.d/www.conf
@@ -1044,13 +1046,7 @@ if [ "$PUID" != "0" ]; then
10441046
sed -i "s|#\?user root;|#user root;|g" /usr/local/nginx/conf/nginx.conf
10451047
exec su-exec "$PUID:$PGID" launch.sh
10461048
else
1047-
find /proc/self/fd \
1048-
/usr/local \
1049-
/data \
1050-
/run \
1051-
/tmp \
1052-
-not \( -uid 0 -and -gid 0 \) \
1053-
-exec chown 0:0 {} \;
1049+
find /data -not \( -uid 0 -and -gid 0 \) -exec chown 0:0 {} \;
10541050
if [ "$PHP82" = "true" ]; then
10551051
sed -i "s|;user =.*|user = root|" /data/php/82/php-fpm.d/www.conf
10561052
sed -i "s|;group =.*|group = root|" /data/php/82/php-fpm.d/www.conf
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
11
location /.well-known/acme-challenge/ {
22
root /tmp/acme-challenge;
3-
fancyindex off;
43
index off;
4+
#fancyindex off;
55
auth_basic off;
66
allow all;
77
}
88

9-
location /fancyindex/ {
10-
alias /html/fancyindex/;
11-
fancyindex off;
12-
index off;
13-
}
14-
159
location ~ /\.ht {
1610
deny all;
1711
}

‎rootfs/usr/local/nginx/conf/nginx.conf

+14-14
Original file line numberDiff line numberDiff line change
@@ -132,20 +132,20 @@ http {
132132
}
133133

134134
# Fancy Index
135-
fancyindex off;
136-
fancyindex_localtime on;
137-
fancyindex_show_path on;
138-
fancyindex_exact_size off;
139-
fancyindex_show_dotfiles off;
140-
fancyindex_hide_symlinks off;
141-
fancyindex_case_sensitive on;
142-
fancyindex_default_sort name;
143-
fancyindex_hide_parent_dir off;
144-
fancyindex_directories_first on;
145-
fancyindex_time_format "%Y-%m-%d %T";
146-
fancyindex_ignore "fancyindex";
147-
fancyindex_header "/fancyindex/header.html";
148-
fancyindex_footer "/fancyindex/footer.html";
135+
index off;
136+
#fancyindex off;
137+
#fancyindex_localtime on;
138+
#fancyindex_show_path on;
139+
#fancyindex_exact_size off;
140+
#fancyindex_show_dotfiles off;
141+
#fancyindex_hide_symlinks off;
142+
#fancyindex_case_sensitive on;
143+
#fancyindex_default_sort name;
144+
#fancyindex_hide_parent_dir off;
145+
#fancyindex_directories_first on;
146+
#fancyindex_time_format "%Y-%m-%d %T";
147+
#fancyindex_header /html/fancyindex/header.html local;
148+
#fancyindex_footer /html/fancyindex/footer.html local;
149149

150150
# Real IP Determination
151151
real_ip_recursive on;

0 commit comments

Comments
 (0)
Please sign in to comment.