librespeed / speedtest

Self-hosted Speed Test for HTML5 and more. Easy setup, examples, configurable, mobile friendly. Supports PHP, Node, Multiple servers, and more
https://librespeed.org
GNU Lesser General Public License v3.0
12.27k stars 2.21k forks source link

Share result image CANN'T show on page #681

Closed wx2020 closed 1 week ago

wx2020 commented 1 week ago

Description

Share result image CANN'T show on page. The image resource appears to be corrupted.

image

Docker Compose file:

  speedtest:
    container_name: speedtest
    image: ghcr.io/librespeed/speedtest:latest
    restart: always
    environment:
      - MODE=standalone
      - TITLE=Speedtest by wx2020
      - WEBPORT=5001
      - TELEMETRY=true
      - ENABLE_ID_OBFUSCATION=true
      - DB_TYPE=sqlite
      - PASSWORD=tCEqt9T7MGGodX
      - EMAIL=example.com
      - IPINFO_APIKEY=xxxxxxxx
      - DISTANCE=km
      - TZ=Asia/Shanghai
    volumes:
      - ./config/speedtest/servers.json:/servers.json
      - ./config/speedtest/database:/database
    network_mode: host
    logging:
      driver: json-file
      options:
        max-size: 1m

Nginx Proxy Server:

server {
    listen 443 ssl;
    listen [::]:443 ssl;
    http2 on;
    http3 on;
    server_name speed.example.com;
    access_log /var/log/nginx/speed.example.com.log;
    error_log /var/log/nginx/speed.example.com.log;
    ssl_certificate /etc/cert/fullchain.cer;
    ssl_certificate_key /etc/cert/example.com.key;
    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_session_timeout 8h;
    ssl_session_cache shared:SSL:20m;
    ssl_session_tickets on;
    add_header Strict-Transport-Security "max-age=31536000" always;
    ssl_trusted_certificate /etc/cert/fullchain.cer;
    ssl_stapling on;
    ssl_stapling_verify on;

    location / {
        client_max_body_size 0;
        client_body_buffer_size 512k;
        client_body_timeout 30s;
        proxy_read_timeout 30s;
        proxy_send_timeout 30s;
        proxy_request_buffering off;
        proxy_redirect off;
        proxy_buffering off;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
        proxy_pass http://localhost:5001;
    }

}

What could be the reason? Please help me.

wx2020 commented 1 week ago

By the way, i used curl to test whether SPEEDTEST container produces an image, and i found that the resource size carried by the result url is 0, obviously no:

image

So the problem should not be caused by nginx.

krutikamin commented 1 week ago

The problem is lack of extensions to generate image. You'll have to modify Dockerfile and use the modified Dockerfile to build image. Replace lines 4-19 in Dockerfile with these lines found from another branch-

# use docker-php-extension-installer for automatically get the right packages installed
ADD --chmod=0755 https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/

# Install extensions
RUN install-php-extensions iconv gd pdo pdo_mysql pdo_pgsql pgsql

RUN rm -f /usr/src/php.tar.xz /usr/src/php.tar.xz.asc \
    && apt autoremove -y \
    && rm -rf /var/lib/apt/lists/*

Hope it helps!

wx2020 commented 1 week ago

Okey, i will try it. Thanks!