Offen is a platform for collecting web analytics in a fair way, i.e. after explicit concent to opt-in and in an anonymised way. Tracking data is not shared with third-parties.
As it is implemented in Golang, Offen is quite lightweight with regards to resource consumption. It can be deployed also on less capable Servers on The Edge.
This guide walks you step by step until you get a Offen published as a service on the Edge that can be accessed on the Internet.
Make sure that all of the mandatory prerequisites have been met before progressing further.
Name | Source | Description |
---|---|---|
<CONTAINER_NAME> | User input | The name of the Linux container where the app will be run. |
<DB_PASSWORD> | User input | The password for logging in with the offen database user in the database. |
<IP_ADDRESS__EDGE_SERVER_VPN> | IP address in VPN | The IPv4 address of the the Server on The Edge in the VPN. |
<ROOT_PWD__CONTAINER> | User input | The password of the root user in the container. |
<IP_ADDRESS__CONTAINER> | Generated | The IPv4 address of the contaier run by the server on the Edge. |
<IP_ADDRESS_INET_GW> | Linux VPS Admin Panel | |
<OFFEN_DOMAIN> | User input | The host for the A record created with your domain registrar, e.g. wa.myowndomain.net . |
Run the following commands on your server on the Edge.
incus launch images:debian/bookworm/cloud <CONTAINER_NAME>
incus exec <CONTAINER_NAME> bash
You may need to change the default MTU for HTTPS connections to function. Run
ip link set dev eth0 mtu 1000
if you findapt update
orapt upgrade
stuck for long time. This setting is non persistent and it is lost when the container reboots.
apt update && apt upgrade && apt install fish
If you are not already within the container, run the following command on your server on the Edge to log in as
root
.
incus exec <CONTAINER_NAME> fish
passwd
Set a password for the root user and make a (mental) note of it. It will be denoted with a variable <ROOT_PWD__CONTAINER>.
From here on the root user will use fish
as default shell.
chsh -s /usr/bin/fish
Let's create the offen
user and set a system password for it.
useradd -m -s /usr/bin/fish offen
passwd offen
The ability to establish SSH connections from the server on the Edge to the container is key for the upcoming Ansible automation. There is an Ansible connection driver for Linux containers with limited capabilities. The default Ansible connection driver through SSH is much more robust and powerful.
You can perform this step now or in future, when you make up your mind to give the automated solutions for system and application maintanence a try.
In order to complete this stage you need to perform the following commands in the container run by the server on the Edge.
apt update && apt install openssh-server
vi /etc/ssh/sshd_config
Add the following line to the file.
PermitRootLogin yes
systemctl enable ssh
systemctl start ssh
systemctl restart ssh
Run the following commands on your server on the Edge, i.e. outside of the container.
Run ssh-keygen
only if you haven't generated SSH private and public keys on the server on the Edge. Otherwise use the already existing pair.
ssh-keygen
incus ls | grep <CONTAINER_NAME>
Make a note of the IPV4 value <IP_ADDRESS__CONTAINER>.
ssh-copy-id root@<IP_ADDRESS__CONTAINER>
Pass the password for the root
user in the container as prompted.
From here on SSH connection as the
root
user will be possible from the server on the Edge to the container. Containers are not visible and accessible to any other network devices.
Run the following commands on your server on the Edge.
incus exec <CONTAINER_NAME> fish
Let's harden the setup of the ssh server running in the container by disabling the password for logging in with root
.
vi /etc/ssh/sshd_config
Delete the line PermitRootLogin yes
.
Append the line PermitRootLogin prohibit-password
.
systemctl restart ssh
You should have a fully functional Linux container named
<CONTAINER_NAME>
that has also a non-administrative useroffen
. In addition, the server on the Edge listens for SSH connections with theroot
user. You know all login credentials.
In order to complete this stage you need to perform the following commands in the container run by the server on the Edge.
If you are not already within the container, run the following command on your server on the Edge to log in as
root
.
incus exec <CONTAINER_NAME> fish
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc|sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/postgresql.gpg
apt update && apt install postgresql-15
In order to enable data checksums we need to delete the existing cluster and initialize it again.
rm -rf /var/lib/postgresql/15/main
mkdir /var/lib/postgresql/15/main
chown -R postgres:postgres /var/lib/postgresql/15/main
chmod 700 /var/lib/postgresql/15/main
sudo -u postgres /usr/lib/postgresql/15/bin/initdb \
-D /var/lib/postgresql/15/main/ \
--locale=C.UTF-8 --encoding=UTF8 --data-checksums
systemctl enable postgresql@15-main.service
systemctl start postgresql@15-main.service
Verify that the stage has been completed successfully by running the following command in the container. Its output should indicate that the service is running.
systemctl status postgresql@15-main.service
In order to complete this stage you need to perform the following commands in the container run by the server on the Edge.
If you are not already within the container, run the following command on your server on the Edge to log in as
root
.
incus exec <CONTAINER_NAME> fish
Take a not of the password for the database user. It will be denoted with a variable <DB_PASSWORD>.
sudo -u postgres createuser offen --interactive --pwprompt
Take a note of the password <DB_PASSWORD>.
sudo -u postgres createdb offen -O offen --encoding='utf-8'
If you are not already within the container, run the following command on your server on the Edge to log in as
root
.
incus exec <CONTAINER_NAME> fish
apt update && apt install -y curl
curl https://keybase.io/hioffen/pgp_keys.asc | gpg --import
curl -sSL https://get.offen.dev/deb -o offen.deb
dpkg -i offen.deb
In order to complete this stage you need to perform the following commands in the container run by the server on the Edge.
If you are not already within the container, run the following command on your server on the Edge to log in as
root
.
incus exec <CONTAINER_NAME> fish
mkdir -p /opt/offen/tls
chown -R offen:offen /opt/offen
sudo -u offen openssl req -x509 -nodes -newkey rsa:4096 -days 365 \
-keyout /opt/offen/tls/key.pem \
-out /opt/offen/tls/cert.pem
If you are not already within the container, run the following command on your server on the Edge to log in as
root
.
incus exec <CONTAINER_NAME> fish
{.is-info}
Run the command below and put the generated secret as a value of the OFFEN_SECRET property in/etc/offen/offen.env
.
offen secret
vi /etc/offen/offen.env
Uncomment and amend or add the following lines. Make sure to substitute the variables enclosed in <...> with the real values matching your setup.
OFFEN_SECRET=<the result of offen secret>
OFFEN_DATABASE_DIALECT="postgres"
OFFEN_DATABASE_CONNECTIONSTRING="postgres://offen:<DB_PASSWORD>@localhost:5432/offen"
OFFEN_SERVER_PORT="8443"
OFFEN_SERVER_REVERSEPROXY=true
OFFEN_SERVER_SSLKEY=/opt/offen/tls/key.pem
OFFEN_SERVER_SSLCERTIFICATE=/opt/offen/tls/cert.pem
If you are not already within the container, run the following command on your server on the Edge to log in as
root
.
incus exec <CONTAINER_NAME> fish
systemctl edit offen.service
Add the following as content of the service extension in the editor that opens.
[Service]
User=offen
Save and exit the systemd service extension editor.
systemctl enable offen
systemctl start offen
systemctl status offen
You should be able to run a successful HTTP request against the Offen server from within the container.
curl -k https://localhost:8443
In a terminal on on the server on the Edge run the following command to forward incoming HTTPS connections on port 13443
of the server to port 8443
on the container.
incus config device add <CONTAINER_NAME> \
https-13443-8443 proxy listen=tcp:0.0.0.0:13443 \
connect=tcp:127.0.0.1:8443
From here on the Buidbot main server instance should be accessible from the Server on the Edge and any other device in the same network.
curl -k https://localhost:13443
Make sure that you have created an A domain record for <OFFEN_DOMAIN> with your domain registrar and you have waited for this record to become active.
If you use a domain name and that's not picked up by the domain name servers yet, Caddy will not be able to serve HTTPS requests because of Let's Encrypt (An SSL certificate authority) failing to verify the validity (ownership over) of the domain.
ssh mycelium@<IP_ADDRESS__INET_GW>
sudo su -
Add the following to /etc/caddy/Caddyfile
.
Do not forget to substitute the variables enclosed in
<...>
with the values matching your setup.
<OFFEN_DOMAIN> {
reverse_proxy https://<IP_ADDRESS__EDGE_SERVER_VPN>:13443 {
transport http {
tls_insecure_skip_verify
}
}
}
systemctl reload caddy
If everything is configured well, you should be able to access the Offen server through its domain name by using a web browser by typing
https://<OFFEN_DOMAIN>
in the address bar.
https://<OFFEN_DOMAIN>/setup
in a web browser. You should be able to create your first account there and log in with Offen./etc/offen/offen.env
to fully benefit from the full functionality and all workflows.