This is a Caddy module that provides a basic HTTP speed
test service, intended to be used via command-line programs like curl
or wget.
-
Using
xcaddy:$ xcaddy build --with maxchernoff.ca/tools/speedtest -
Using
caddy add-package(not recommended):$ caddy add-package maxchernoff.ca/tools/speedtest -
Manually, by visiting
caddyserver.com/downloadand selectingmaxchernoff.ca/tools/speedtestfrom the list of plugins.
Add the following to your Caddyfile:
example.com {
speedtest /speedtest
}To test download speed:
$ curl --output /dev/null --progress-meter https://example.com/speedtest?bytes=100MB
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 95.3M 100 95.3M 0 0 410M 0 --:--:-- --:--:-- --:--:-- 411MTo test upload speed:
$ head --bytes=100M /dev/urandom | curl --output /dev/null --progress-meter --form file=@- https://example.com/speedtest
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 100M 100 23 100 100M 149 651M --:--:-- --:--:-- --:--:-- 649MA public instance of this service is hosted on my personal server. The
server is fairly slow, so under no circumstances should you use it
in any scripts or include its URL in any lists of speed
test services. However, feel free to use it for manually by typing a
curl/wget command into your terminal.
As long as you follow the usage instructions above, you can access it at
www.maxchernoff.ca/tools/speedtest.
There are a plethora of speed test services available online, but none of them meet all the following criteria:
-
Must be directly usable from
curl. -
Must support uploading files of arbitrary size.
-
Must have a fixed geographical location (no anycast).
Since I'm already using Caddy for other purposes, the easiest solution was to write a Caddy module that provides this functionality.
The source code for this module is hosted on GitHub at
github.com/gucci-on-fleek/caddy-speedtest.