Skip to content

Set up the host (OpenBSD)

As root, unpack the verified tarball and run the setup with the host name and the registry the releases come from:

mkdir /tmp/fm && tar -xzf flyingmonit-<version>_openbsd-8.0_arm64.tar.gz -C /tmp/fm
/tmp/fm/openbsd/setup.sh flyingmonit.example.com https://gitlab.pallach.de/api/v4/projects/138/packages/generic/flyingmonit

It does only what is not done yet, so it can run again; existing settings are kept:

  1. The user _flyingmonit, and /home/flyingmonit/ with releases/, backups/, db/ and tmp/.
  2. /etc/flyingmonit.env: the server's settings, with a new random SECRET_KEY_BASE.
  3. /etc/flyingmonit-update.conf: the registry the updates come from (public: no token).
  4. /etc/rc.d/flyingmonit, /usr/local/sbin/flyingmonit-update and the release key /etc/signify/flyingmonit.pub.
  5. The service enabled, and flyingmonit-update in root's crontab, every minute.

Then, by hand:

relayd

Forward the host name to FlyingMonit, beside the other hosts in /etc/relayd.conf:

table <flyingmonit_service> { 127.0.0.1, 127.0.0.2 }
match request header set "X-Forwarded-For" value "$REMOTE_ADDR"
pass request quick header "Host" value "flyingmonit.example.com" forward to <flyingmonit_service>
pass request quick header "Host" value "flyingmonit.example.com:443" forward to <flyingmonit_service>
forward to <flyingmonit_service> port 8090 check http "/health" code 200

Two addresses: an update starts the new release beside the running one on the other address and switches relayd to it -- FlyingMonit is not down. The second one is an alias of the loopback, now and at boot:

printf 'inet alias 127.0.0.2 255.255.255.255\n' >/etc/hostname.lo0
ifconfig lo0 alias 127.0.0.2/32

Without 127.0.0.2 in the table, an update stops FlyingMonit for a few seconds.

!!! note "Both Host rules" Monit's agents send the port in the Host header: without the second rule their reports reach relayd's first table instead.

!!! warning "The client's address" The X-Forwarded-For rule goes in the relay's http protocol before every pass request quick rule -- quick ends the evaluation, a rule after it never applies. FlyingMonit counts failed logins per client address and answers /ip with it: without the rule every client is 127.0.0.1. It reads the header's last address, the one relayd adds; set leaves no other in it. Check it after the setup: curl -s https://flyingmonit.example.com/ip answers your address.

The pages talk to the server over a WebSocket, which relayd refuses unless its http protocol allows it -- without this line the pages load, but no form works:

http protocol "https" {
        http websockets
        # ... its other options
}

acme-client

Add the host name as an alternative name in /etc/acme-client.conf, then:

acme-client <domain> && rcctl reload relayd

The first install

Afterwards cron does it – the first time, by hand:

/usr/local/sbin/flyingmonit-update

The first admin

Its password is printed once:

cd /home/flyingmonit && su -s /bin/sh _flyingmonit -c 'set -a; . /etc/flyingmonit.env; set +a;
  /home/flyingmonit/current/bin/flying_monit eval "FlyingMonit.Release.create_user(\"admin\", \"admin\")"'

Log in at https://flyingmonit.example.com/ and change the password on the profile page. There is no default login.

Next: point your Monit agents at it.