Skip to content

Commit 362a1f1

Browse files
committed
fix(docker): raise PHP post_max_size for default 20MB upload chunks
speedtest_worker.js uploads in 20 MB chunks by default (xhr_ul_blob_megabytes: 20) but the official Docker images inherit PHP's stock post_max_size = 8M / upload_max_filesize = 2M, so every upload chunk: * triggers a "POST Content-Length ... exceeds the limit" warning (leaked into the response body of /backend/empty.php on the Debian variant where display_errors is on; suppressed but still emitted on Alpine where it's off); * causes empty.php's subsequent header() calls to fail with "Cannot modify header information - headers already sent", leaving the response without proper status, cache, or CORS directives. Ship a small docker/librespeed-php.ini with post_max_size = 32M, upload_max_filesize = 32M, memory_limit = 256M and COPY it into the right conf.d for each base image (/usr/local/etc/php/conf.d on Debian, /etc/php84/conf.d on Alpine). 99- prefix follows the NN-name.ini packaging convention so this loads after distro defaults but never silently shadows operator overrides. Verified post-fix on both variants: a 20 MB POST to /backend/empty.php returns HTTP 200 / 0 bytes with no warning leakage.
1 parent 853214d commit 362a1f1

3 files changed

Lines changed: 30 additions & 0 deletions

File tree

Dockerfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ RUN install-php-extensions iconv gd pdo pdo_mysql pdo_pgsql pgsql \
1010
&& apt-get clean \
1111
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
1212

13+
COPY docker/librespeed-php.ini /tmp/librespeed-php.ini
14+
RUN scan_dir="$(php -r 'echo rtrim(PHP_CONFIG_FILE_SCAN_DIR);')" \
15+
&& [ -n "$scan_dir" ] \
16+
&& install -D -m 0644 /tmp/librespeed-php.ini "$scan_dir/99-librespeed.ini" \
17+
&& rm /tmp/librespeed-php.ini
18+
1319
# Prepare files and folders
1420
RUN mkdir -p /speedtest/
1521

Dockerfile.alpine

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ RUN apk add --quiet --no-cache \
2424
RUN ln -sf /dev/stdout /var/log/apache2/access.log && \
2525
ln -sf /dev/stderr /var/log/apache2/error.log
2626

27+
COPY docker/librespeed-php.ini /tmp/librespeed-php.ini
28+
RUN scan_dir="$(/usr/bin/php -r 'echo rtrim(PHP_CONFIG_FILE_SCAN_DIR);')" \
29+
&& [ -n "$scan_dir" ] \
30+
&& install -D -m 0644 /tmp/librespeed-php.ini "$scan_dir/99-librespeed.ini" \
31+
&& rm /tmp/librespeed-php.ini
32+
2733
# Prepare files and folders
2834
RUN mkdir -p /speedtest/
2935

docker/librespeed-php.ini

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
; LibreSpeed-recommended PHP override.
2+
;
3+
; speedtest_worker.js uploads in 20 MB chunks by default
4+
; (xhr_ul_blob_megabytes: 20). PHP's stock post_max_size = 8M rejects
5+
; every chunk: it emits a "POST Content-Length ... exceeds the limit"
6+
; startup warning and prevents empty.php from sending its response
7+
; headers (Cache-Control, Pragma, Connection, and CORS under ?cors).
8+
;
9+
; The upload throughput number is unaffected (the worker measures
10+
; bytes-on-wire via xhr.upload.onprogress, not the response body).
11+
;
12+
; 32M is the next round number above the worker's 20M default.
13+
; upload_max_filesize and memory_limit don't need to change for this
14+
; workload — empty.php discards php://input and never reads multipart
15+
; form data, so the stock 2M / 128M defaults are not on the upload
16+
; codepath.
17+
18+
post_max_size = 32M

0 commit comments

Comments
 (0)