From 82d64bff9692bc0ee13a43d1ff6253440fd5ac55 Mon Sep 17 00:00:00 2001 From: JoKneeMo <421625+JoKneeMo@users.noreply.github.com> Date: Sun, 11 Dec 2022 22:57:06 -0500 Subject: [PATCH 1/3] Set content-type before sending image data for a valid response --- results/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/results/index.php b/results/index.php index ad6beca..2505058 100755 --- a/results/index.php +++ b/results/index.php @@ -212,7 +212,6 @@ function drawImage($speedtest) imagefttext($im, $FONT_WATERMARK_SIZE, 0, $POSITION_X_WATERMARK, $POSITION_Y_WATERMARK, $TEXT_COLOR_WATERMARK, $FONT_WATERMARK, $WATERMARK_TEXT); // send the image to the browser - header('Content-Type: image/png'); imagepng($im); } @@ -221,4 +220,5 @@ if (!is_array($speedtest)) { exit(1); } +header('Content-Type: image/png'); drawImage($speedtest); From 20f1f46d1fc5fd300ad86da2717929bfb7d8ae2f Mon Sep 17 00:00:00 2001 From: JoKneeMo <421625+JoKneeMo@users.noreply.github.com> Date: Sun, 11 Dec 2022 23:08:46 -0500 Subject: [PATCH 2/3] Docker support for a server that behaves as a standalone frontend AND a backend for another server. --- doc_docker.md | 7 +++++++ docker/entrypoint.sh | 6 +++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/doc_docker.md b/doc_docker.md index 753fe02..53eabb0 100755 --- a/doc_docker.md +++ b/doc_docker.md @@ -104,3 +104,10 @@ This command starts LibreSpeed in frontend mode, with a given `servers.json` fil ``` docker run -e MODE=frontend -e TELEMETRY=true -e ENABLE_ID_OBFUSCATION=true -e PASSWORD="yourPasswordHere" -v $(pwd)/servers.json:/servers.json -p 80:80 -it adolfintel/speedtest ``` + +### Dual mode +In dual mode, LibreSpeed operates as a standalone server that can also connect to other test points. +To do this: +* Set the `MODE` environment variable to `dual` +* Follow the `servers.json` instructions for the frontend mode +* The first server entry should be the local server, using the server endpoint address that a client can access. \ No newline at end of file diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index d08ff05..92ea473 100755 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -13,7 +13,7 @@ cp /speedtest/*.js /var/www/html/ cp /speedtest/favicon.ico /var/www/html/ # Set up backend side for standlone modes -if [ "$MODE" == "standalone" ]; then +if [[ "$MODE" == "standalone" || "$MODE" == "dual" ]]; then cp -r /speedtest/backend/ /var/www/html/backend if [ ! -z "$IPINFO_APIKEY" ]; then sed -i s/\$IPINFO_APIKEY\ =\ \'\'/\$IPINFO_APIKEY\ =\ \'$IPINFO_APIKEY\'/g /var/www/html/backend/getIP_ipInfo_apikey.php @@ -28,14 +28,14 @@ if [ "$MODE" == "backend" ]; then fi # Set up index.php for frontend-only or standalone modes -if [ "$MODE" == "frontend" ]; then +if [[ "$MODE" == "frontend" || "$MODE" == "dual" ]]; then cp /speedtest/frontend.php /var/www/html/index.php elif [ "$MODE" == "standalone" ]; then cp /speedtest/standalone.php /var/www/html/index.php fi # Apply Telemetry settings when running in standalone or frontend mode and telemetry is enabled -if [[ "$TELEMETRY" == "true" && ( "$MODE" == "frontend" || "$MODE" == "standalone" ) ]]; then +if [[ "$TELEMETRY" == "true" && ( "$MODE" == "frontend" || "$MODE" == "standalone" || "$MODE" == "dual" ) ]]; then cp -r /speedtest/results /var/www/html/results if [ "$MODE" == "frontend" ]; then From 11f698b376969c59d9d1e7f29eb86f1d1759ee29 Mon Sep 17 00:00:00 2001 From: JoKneeMo <421625+JoKneeMo@users.noreply.github.com> Date: Wed, 8 Nov 2023 11:05:47 -0500 Subject: [PATCH 3/3] Revert "Set content-type before sending image data for a valid response" This reverts commit 82d64bff9692bc0ee13a43d1ff6253440fd5ac55. --- results/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/results/index.php b/results/index.php index 2505058..ad6beca 100755 --- a/results/index.php +++ b/results/index.php @@ -212,6 +212,7 @@ function drawImage($speedtest) imagefttext($im, $FONT_WATERMARK_SIZE, 0, $POSITION_X_WATERMARK, $POSITION_Y_WATERMARK, $TEXT_COLOR_WATERMARK, $FONT_WATERMARK, $WATERMARK_TEXT); // send the image to the browser + header('Content-Type: image/png'); imagepng($im); } @@ -220,5 +221,4 @@ if (!is_array($speedtest)) { exit(1); } -header('Content-Type: image/png'); drawImage($speedtest);