speedtest icon indicating copy to clipboard operation
speedtest copied to clipboard

Signifficantly slower speeds when behind nginx

Open yurividal opened this issue 1 year ago • 1 comments

Hi. I am running this project using the ghcr.io/librespeed/speedtest docker image. In order to expose it to the internet, i have put it behind an nginx reverse proxy. But i noticed the speed tests are significantly slower when behing the nginx and https.

what is the recommended way of exposing the docker version of librespeed? The image doesn't seem to include any ssl modules.

This is my nginx config:

location / {
        proxy_set_header Host $http_host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-Host $http_host;
        proxy_set_header X-Forwarded-Server $http_host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        gzip off;
        proxy_redirect off;
        proxy_buffering off;
        client_max_body_size 256M;
        proxy_pass http://librespeed:8080/;
    }

yurividal avatar Dec 02 '24 12:12 yurividal

Is nginx handling encryption, i.e. https? If so, it's probably just your server having to encrypt/decrypt all messages. Check your cpu consumption, in my case my server is just not strong enough to handle that.

witchent avatar Apr 14 '25 07:04 witchent

My observation here is that nginx doesn't add any additional overhead really. Connected with a 10G link, I cannot seem to get more than ~6Gbps down or 3-4Gbps up when using either nginx or speedtest-rust directly (both with TLS enabled). I haven't tested without TLS, because frankly I think it's not a useful metric anyway- nobody should be running anything without TLS really.

frebib avatar Aug 09 '25 09:08 frebib

I didn't try the speedtest-rust, but I can see on my homeserver that nginx with TLS is using up all my CPU. I guess if you have a beefier setup it doesn't matter, but if you're CPU bound then TLS might be more than the server can handle.

witchent avatar Aug 11 '25 21:08 witchent

I'm experiencing this issue with caddy2 as a reverse-proxy. Speeds cap between 550-750mbps. Wire speed and speed over http ip is near 2500/2500. CPU usage of the server peaks below 7% of 6 Zen2 cores during download test and <3% during upload test.

mokahless avatar Oct 10 '25 20:10 mokahless