8 · FerrumKix in the browser

Sometimes the music lives on a computer you are not sitting at: a small server in the hallway with the speakers attached but no screen, or the big machine in the study while you are on the sofa. For that, FerrumKix can show itself in a web browser instead of in a window, the same way FerrumPix does.

FerrumKix in a browser window

It is the same FerrumKix with everything it can do: playlist, Lyrion, tag editor, converter and settings. Nothing is installed on the device you sit at; a browser is enough.

Good to know: The sound stays where FerrumKix runs. The browser is the screen and the remote control. The music comes out of the speakers of the computer FerrumKix was started on, not out of the tablet or phone that has the page open.

Trying it on your own computer

Start FerrumKix with --browser:

ferrumkix --browser

ferrumkix, in lowercase, is the command the Linux packages install. The AppImage is started by its file name:

./FerrumKix-0.9.12-4-x86_64.AppImage --browser

No window opens. FerrumKix tells you the address instead, http://127.0.0.1:14500. Open it in the browser, and FerrumKix fills the tab. Close the tab and come back later, and everything is as you left it; the music keeps playing in the meantime.

Leave the terminal open while you use FerrumKix. FerrumKix runs in that terminal, and closing it ends FerrumKix; the page in the browser then stops reacting.

There is only one FerrumKix at a time. If it is already running with a window, close it first. Otherwise a second start with --browser ends with a message instead of silently doing nothing.

One browser at a time

Exactly one browser is connected at any time. If you open FerrumKix in a second tab or on another device, that one takes over the session and the first one is left out. There is only one interface with one size, and two tabs would fight over it.

With a sign-in

If you want a sign-in in front of it, give FerrumKix a password and, if you like, a user name. The browser then asks for them with its own sign-in dialog before it shows anything:

ferrumkix --browser --browser-user=anna --browser-password=secret

A user name without a password does not work; FerrumKix then does not start and tells you what is missing.

From another device

To reach FerrumKix from another device in the network, such as a tablet or a phone, one more thing is needed. FerrumKix does not encrypt the connection itself, and a password travelling through the network unprotected could be read by anyone listening. So FerrumKix only lets other devices in through a reverse proxy that provides HTTPS, the kind of small web server many people already run in front of their home services.

Tell FerrumKix that the proxy is there, and a password becomes mandatory:

ferrumkix --browser --browser-tls-proxy --browser-user=anna --browser-password=secret

If you start it for other devices without that, FerrumKix does not start and tells you why. That is on purpose: it is better to be told once than to find out later that your password was readable.

What the proxy has to do

Behind the proxy, FerrumKix only accepts requests that really come from the proxy and that the proxy marks as having arrived encrypted. Anyone calling the port past the proxy is turned away before being asked for a name and password. So FerrumKix needs from the proxy:

  • the header X-Forwarded-Proto: https,
  • forwarding of WebSocket connections; the pictures travel to the browser and the input comes back through them, on the path /ws,
  • the host the page was opened under in the browser, as Host or as X-Forwarded-Host.

If the proxy runs on the same computer as FerrumKix, FerrumKix stays on its address 127.0.0.1:14500, and the proxy passes the requests on to it. With Caddy, which brings HTTPS, the X-Forwarded headers and WebSockets on its own, this is enough, for example:

music.example.org {
    reverse_proxy 127.0.0.1:14500
}

If the proxy runs on a different computer, FerrumKix has to listen on an address in the network, and then every computer in the network reaches the port, not only the proxy. In that case, name the address of the proxy so FerrumKix knows whom to trust:

ferrumkix --browser --browser-tls-proxy --browser-bind=0.0.0.0:14500 \
  --browser-proxy-address=192.168.1.2 --browser-user=anna --browser-password=secret

Without --browser-proxy-address FerrumKix does not start in that case and tells you what is missing.

All settings

Everything you can pass on the command line can also come from the environment. That is handy for a service and keeps the password out of the list of running programs, where every user of the computer could see it otherwise:

env FERRUMKIX_BROWSER_USER=anna FERRUMKIX_BROWSER_PASSWORD=secret ferrumkix --browser
On the command line In the environment What it does
--browser shows FerrumKix in the browser instead of a window
--browser-bind=127.0.0.1:8080 FERRUMKIX_BROWSER_BIND address and port, 127.0.0.1:14500 by default; 0.0.0.0 listens on all addresses
--browser-user=anna FERRUMKIX_BROWSER_USER the user name for the sign-in
--browser-password=secret FERRUMKIX_BROWSER_PASSWORD the password for the sign-in
--browser-tls-proxy FERRUMKIX_BROWSER_TLS_PROXY=1 a reverse proxy with HTTPS stands in front
--browser-proxy-address=192.168.1.2 FERRUMKIX_BROWSER_PROXY_ADDRESS where the proxy runs, if on a different computer; several addresses separated by commas; only together with the proxy
FERRUMKIX_BROWSER_LOCAL_FORWARD=1 for containers: listen on all addresses, but only accept requests addressed to the computer itself (127.0.0.1 or localhost)

The command line option takes precedence over the environment variable.

What is different in the browser

This is a first version. A few things do not work in the browser, or work differently than in the window:

  • Files come from the computer FerrumKix runs on. You cannot drop files onto the page or upload them from the device you sit at. The playlist takes them from the computer running FerrumKix, through its own file dialog.
  • Copy and paste stay inside FerrumKix. The page exchanges nothing with the clipboard of your device.
  • No symbol in the notification area, no window buttons, no moving and no resizing. The window fills the tab and follows its size; in this mode FerrumKix does not write its position and size into the settings.
  • The slim bar is not available in the browser.
  • A little less quick. The computer draws everything without the help of its graphics card, so it feels a little slower than the window, mostly with very large browser windows.