openspeedtest / Docker-Image

OpenSpeedTest Docker Image
132 stars 30 forks source link

Inaccurate upload speeds: these settings work on everything but iPad OS and iOS when using Wi-Fi #28

Open dimepues opened 3 months ago

dimepues commented 3 months ago

Hi all,

I'm having success on all platforms but iOS and iPad OS when using Wi-Fi πŸ˜‹ and wanted to share my setup / settings. Enjoy!

Numbers I'm seeing on Wi-Fi 6E 6ghz:

Numbers I'm seeing on Wi-Fi 6 5ghz:

My Setup:

Docker Compose: Nginx

version: '3.8'

networks:
  apps-general:  
    external: true
  paperless-ngx:
    external: true

services:
  nginx:
    image: nginx:latest
    container_name: nginx
    restart: unless-stopped
    ports:
      - '80:80'
    volumes:
      - /home/ubuntu/nginx-configs/apps.conf:/etc/nginx/conf.d/apps.conf
    networks:
      - apps-general

Docker Compose: OpenSpeedTest

version: '3.3'

services:
  speedtest:
    image: openspeedtest/latest
    restart: unless-stopped
    container_name: openspeedtest

    networks:
      - apps-general

networks:
  apps-general:
    external: true

OpenSpeedTest Portion of apps.conf

Partially sourced from this configuration:

server {
    listen 80;
    server_name speed.apps.home.domain.com;

    location / {
        # Proxy pass directive to route requests to the OpenSpeedTest container
        proxy_pass http://openspeedtest:3000/;
        proxy_http_version 1.1; # Ensure HTTP/1.1 is used for this location
        # Standard headers for proxying
        proxy_set_header Host $host;
        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 $scheme;

        # Additional headers to ensure correct handling
        add_header 'Access-Control-Allow-Origin' "*" always;
        add_header 'Access-Control-Allow-Headers' 'Accept,Authorization,Cache-Control,Content-Type,DNT,If-Modified-Since,Keep-Alive,Origin,User-Agent,X-Mx-ReqToken,X-Requested-With' always;
        add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
        add_header Cache-Control 'no-store, no-cache, max-age=0, no-transform';
        add_header Last-Modified $date_gmt;
        if_modified_since off;
        expires off;
        etag off;

        # Handle OPTIONS requests
        if ($request_method = OPTIONS ) {
            add_header 'Access-Control-Allow-Credentials' "true";
            add_header 'Access-Control-Allow-Headers' 'Accept,Authorization,Cache-Control,Content-Type,DNT,If-Modified-Since,Keep-Alive,Origin,User-Agent,X-Mx-ReqToken,X-Requested-With' always;
            add_header 'Access-Control-Allow-Origin' "$http_origin" always;
            add_header 'Access-Control-Allow-Methods' "GET, POST, OPTIONS" always;
            return 200;
        }
    }
}
vishnunuk commented 3 months ago

@dimepues Maybe we need to add error_page 405 =200 $uri; Safari's XHR progress event may not trigger on very fast networks, so we calculate the exchanged value manually. If the server returns a status before receiving the POST body, we may observe abnormal upload speeds. This issue is due to abnormal server behavior. the server should wait for the POST body before returning a 200 status. I have not tested but this may help proxy_buffering on;

Or try to handle the /upload like this.

  location = /upload {
         proxy_pass http://127.0.0.1:3000/dev-null;
       }
       location = /dev-null {
           return 200;
       }

Check the browser console's Network tab to see the error message you're getting for the upload. Ensure that the server is responding using HTTP/1.1, which is necessary for establishing parallel connections.

dimepues commented 3 months ago

Thanks for the timely reply.

I'll give the nginx rule a shot tomorrow 🍻