Skip to content

Commit 8ed590f

Browse files
h4x3rotabclaude
andcommitted
Replace inline Python http.server with mini-httpd
The evidence file server was using an inline Python ThreadingTCPServer, which is hacky and not battle-tested for production use. Replace it with mini-httpd (1.30), a proven static file server by Jef Poskanzer (author of thttpd). At 123 KB installed, it is the smallest proper HTTP server in Debian bookworm that handles concurrent connections (fork-per-request). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent c1a57c3 commit 8ed590f

3 files changed

Lines changed: 7 additions & 10 deletions

File tree

custom-domain/dstack-ingress/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ RUN --mount=type=bind,source=pinned-packages.txt,target=/tmp/pinned-packages.txt
3030
python3.11-venv \
3131
curl \
3232
jq \
33-
coreutils && \
33+
coreutils \
34+
mini-httpd && \
3435
rm -rf /var/lib/apt/lists/* /var/log/* /var/cache/ldconfig/aux-cache
3536

3637
RUN mkdir -p \

custom-domain/dstack-ingress/pinned-packages.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,9 @@ libzstd1:amd64=1.5.4+dfsg2-5
104104
login=1:4.13+dfsg1-1+deb12u1
105105
logsave=1.47.0-2
106106
mawk=1.3.4.20200120-3.1
107+
lsb-base=11.6
107108
media-types=10.0.0
109+
mini-httpd=1.30-3
108110
mount=2.38.1-5+deb12u3
109111
ncurses-base=6.4-4
110112
ncurses-bin=6.4-4

custom-domain/dstack-ingress/scripts/entrypoint.sh

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -404,16 +404,10 @@ elif [ -n "$DOMAIN" ] && [ -n "$TARGET_ENDPOINT" ]; then
404404
setup_haproxy_cfg
405405
fi
406406

407-
# Start evidence HTTP server if enabled (threaded to avoid blocking on slow clients)
407+
# Start evidence HTTP server if enabled
408408
if [ "$EVIDENCE_SERVER" = "true" ]; then
409-
python3 -c "
410-
import http.server, socketserver, os
411-
os.chdir('/evidences')
412-
handler = http.server.SimpleHTTPRequestHandler
413-
with socketserver.ThreadingTCPServer(('', ${EVIDENCE_PORT}), handler) as s:
414-
s.serve_forever()
415-
" &
416-
echo "Evidence server started on port ${EVIDENCE_PORT}"
409+
mini_httpd -d /evidences -p "${EVIDENCE_PORT}" -D -l /dev/stderr &
410+
echo "Evidence server started on port ${EVIDENCE_PORT} (mini_httpd)"
417411
fi
418412

419413
renewal-daemon.sh &

0 commit comments

Comments
 (0)