Speed-Test icon indicating copy to clipboard operation
Speed-Test copied to clipboard

Fix upload speeds when using Nginx for reverse proxy

Open lightmaster opened this issue 2 years ago • 2 comments

I'm trying to get OpenSpeedTest working behind my Nginx based reverse proxy, but I'm getting impossibly high upload speeds (12Gbps on a 1Gbps NIC). I've seen on one of the other closed issues about disabling compression on Traefik to get upload working, but I can't figure out how to get it working on Nginx.

If it makes a difference, this is from hijacking the built in Nginx on a Synology NAS. I know very little about Nginx, so I started with a generated one from Synology's settings app and adjusted it to disable gzip and increase client_body_max_size

Current .conf:

###
### OpenSpeedTest
###

server {
        listen 80;
        listen [::]:80;
        server_name ost.example.com;

        # Include this if you want to get a letsencrypt certificate for the domain you're using
        location ^~ /.well-known/acme-challenge/ {
                auth_basic off;
                root /var/lib/letsencrypt;
                default_type "text/plain";
        }

        # Include this if you want to automatically redirect to HTTPS
        location / {
                return 301 https://$server_name$request_uri;
        }
}

server {

        listen 443 ssl;
        listen [::]:443 ssl;
        server_name ost.example.com;

        # Include these if you want to use a specific certificate,
        # you'll need to find the location of the letsencrypt after you get it...
        # so this might need to be updated afterwards
        # ssl_certificate /usr/syno/etc/certificate/_archive/TI0h6w/fullchain.pem;
        # ssl_certificate_key /usr/syno/etc/certificate/_archive/TI0h6w/privkey.pem;
        # add_header Strict-Transport-Security "max-age=15768000; includeSubdomains; preload" always;

        # Include this if you want basic authentication required
        #auth_basic “Restricted”;
        #auth_basic_user_file /etc/nginx/.htpasswd;

        location ^~ /.well-known/acme-challenge/ {
                auth_basic off;
                root /var/lib/letsencrypt;
                default_type "text/plain";
        }

        location / {

                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;
                proxy_set_header        Upgrade                         $http_upgrade;
                proxy_set_header        Connection                      $connection_upgrade;
                client_max_body_size 100000M;
                gzip off;
                fastcgi_read_timeout 999;

                proxy_pass          http://localhost:3000/;
                proxy_read_timeout  90;

        }

  }

lightmaster avatar Aug 24 '22 23:08 lightmaster

Look at browser console for errors. You might want to enable post to Static file. It's http 1.1 right. Look the Nginx configuration posted on my GitHub profile.

openspeedtest avatar Aug 25 '22 01:08 openspeedtest

I tested your configuration, It shows invalid for me.

server {

        listen 80;
       
 
       
        location / {

             
                client_max_body_size 10000M;

                proxy_pass          http://localhost:3000/;
             

        }

  }

I proxy pass with this bock of code on my machine. to a localhost 3000, download and upload worked fine. I think you need to fix your Nginx config. Test SSL without OpenSpeedTest with a simple html file. if you can see the page with SSL on your domain, then try openspeedtest. if you found unusual result, first look at browser console and network tab for errors.

openspeedtest avatar Aug 25 '22 05:08 openspeedtest