I needed a mobile speed test server for my network diagnostics laptop recently. I have been using LibreSpeed in the office for quite some time so along with iperf3 on the same laptop, it was the logical choice.
First I created a VNET jail and updated it ready for use. BastilleBSD is my choice for jail management:
bastille create -T -B speed 13.0-RELEASE 192.168.1.10/24 lan
bastille update speed
As I also run bhyve guests on the laptop, I want the jail to bind to existing bridges that are managed by vm-bhyve. Once updates are complete, console into the jail to install and configure LibreSpeed:
bastille console speed
For LibreSpeed, FreeBSD already has it in ports/pkgs so we just need that package and a web server. We will be using Nginx in this instance:
pkg install -y librespeed-php81 nginx
Enable nginx and php-fpm to be able to launch them with the service command:
service nginx enable && service php-fpm enable
Copy the example HTML file to the LibreSpeed directory that is suitable for your environment:
cd /usr/local/share/examples/librespeed
cp -a example-singleServer-full.html /usr/local/www/librespeed/index.html
The default /usr/local/etc/nginx/nginx.conf file needs some tweaking to make things work correctly. Below is a diff between the FreeBSD -dist file and what was used in this configuration:
--- nginx.conf-dist 2022-02-12 12:51:09.000000000 +1100 +++ nginx.conf 2022-02-17 14:08:34.731739000 +1100 @@ -39,16 +39,14 @@ http { server { listen 80; - server_name localhost; + server_name _; + root /usr/local/www/librespeed; + index index.html index.htm; #charset koi8-r; #access_log logs/host.access.log main; - location / { - root /usr/local/www/nginx; - index index.html index.htm; - } #error_page 404 /404.html; @@ -67,13 +65,12 @@ http { # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # - #location ~ \.php$ { - # root html; - # fastcgi_pass 127.0.0.1:9000; - # fastcgi_index index.php; - # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; - # include fastcgi_params; - #} + location ~ \.php$ { + fastcgi_pass 127.0.0.1:9000; + fastcgi_index index.php; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + include fastcgi_params; + } # deny access to .htaccess files, if Apache's document root # concurs with nginx's one
That is all that is needed. Simply start nginx and php-fpm, point your browser to the IP address of the instance and you can test any device that has network connectivity to your jail.