Reverse proxy with Apache
To expose the locally running service to the internet you need to configure a reverse proxy. Depending on how you run the service (Docker, Go binary) you need to change the port in the config below.
You also need to obtain a SSL certificate from for example Let's Encrypt with certbot.
IPv4 and IPv6 is intentionally separate, otherwise it is not possible to forward the IPv6 address from the client to the backend.
If you do not have IPv6 please remove the IPv6 blocks from the virtual host below.
# IPv4 plain HTTP
<VirtualHost Your.Public.IPv4.Address:80>
ServerName librespeed.example.org
ProxyRequests Off
ProxyPreserveHost On
ErrorLog /dev/null
CustomLog /dev/null combined
<Location />
ProxyPass http://127.0.0.1:<port>/
ProxyPassReverse http://127.0.0.1:<port>/
</Location>
</VirtualHost>
# IPv6 plain HTTP
<VirtualHost [Your:Public:IPv6::Address]:80>
ServerName librespeed.example.org
ProxyRequests Off
ProxyPreserveHost On
ErrorLog /dev/null
CustomLog /dev/null combined
<Location />
ProxyPass http://[::]:<port>/
ProxyPassReverse http://[::]:<port>/
</Location>
</VirtualHost>
# IPv4 encrypted HTTPS
<VirtualHost Your.Public.IPv4.Address:443>
ServerName librespeed.example.org
Protocols h2 h2c http/1.1
ProxyRequests Off
ProxyPreserveHost On
ErrorLog /dev/null
CustomLog /dev/null combined
SSLEngine On
SSLCertificateFile /path/to/fullchain.pem
SSLCertificateKeyFile /path/to/privkey.pem
SSLCertificateChainFile /path/to/chain.pem
<Location />
ProxyPass http://127.0.0.1:<port>/
ProxyPassReverse http://127.0.0.1:<port>/
</Location>
</VirtualHost>
# IPv6 encrypted HTTPS
<VirtualHost [Your:Public:IPv6::Address]:443>
ServerName librespeed.example.org
Protocols h2 h2c http/1.1
ProxyRequests Off
ProxyPreserveHost On
ErrorLog /dev/null
CustomLog /dev/null combined
SSLEngine On
SSLCertificateFile /path/to/fullchain.pem
SSLCertificateKeyFile /path/to/privkey.pem
SSLCertificateChainFile /path/to/chain.pem
<Location />
ProxyPass http://[::]:<port>/
ProxyPassReverse http://[::]:<port>/
</Location>
</VirtualHost>