June 12, 2020

Need a reservation system? Alf.IO is amazing.

By jfbethlehem
Spread the love

The new Corona laws require churches to limit the amount of people coming to physical churches. Every church has to keep at least 1.5 meters distance between all churchgoers. If the church cannot do this, we run the risk of getting a serious fine. Also, currently we are only allowed to have at most 30 churchgoers in the church IF we have a large enough building to fit ‘all’ those people (we don’t). In July of 2020, theoretically we can fit up to 100 people.

To help us limit the amount of people coming to church, I have installed a ticketing system. This allows our members to ‘purchase’ a ticket (for free) and come to church. They will receive a confirmation email and a QR code which can be scanned at the location.

The software I used is Alf.io. It’s a complete professional looking web application based on Java. To be honest, I am amazed they aren’t charging a lot more for it as it works very professionally.

The Alf.io website, unfortunately does not have a very good installation manual. They only describe how to install on a few cloud hosting providers but not manual installation.

I did the following steps (copied & modified from here):

1: Install an Ubuntu or Debian machine (if you don’t already have one) & log in to it. Set a DNS entry of reserveration.yourdomain.church (change to reflect your settings) to the IP address of your server. This is something you will have to figure out yourself as every hosting and cloud provider does it differently.

2: Install the required software:

sudo apt-get install openjdk-11-jre postgresql postgresql-contrib nginx -y

3: Configure PostgreSQL database:

CREATE USER alfio WITH ENCRYPTED PASSWORD '<YOUR_POSTGRESQL_PASSWORD_HERE>';
CREATE DATABASE alfio;
GRANT ALL PRIVILEGES ON DATABASE "alfio" to alfio;

4: Configure nginx:

sudo nano /etc/nginx/sites-available/default

comment the server {….} entry and add this:

server {
server_name reservation.yourdomain.church;
  location / {
    proxy_pass http://localhost:8080;
  }
  proxy_set_header X-Forwarded-Proto $thescheme;
  proxy_set_header X-Forwarded-Host $host:$server_port;
  proxy_set_header X-Forwarded-Server $host;
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
map $http_x_forwarded_proto $thescheme {
     default $scheme;
     https https;
 }  

5: Create an alf.io user:

sudo adduser alfio

6: Create a systemd entry:

nano /usr/lib/systemd/system/alfio.service

[Unit]
Description=alfio
After=postgresql.service
Requires=postgresql.service

[Service]
User=alfio
WorkingDirectory=/home/alfio
ExecStart=/home/alfio/start.sh
ExecStop=/bin/kill -TERM $MAINPID
Restart=always

[Install]
WantedBy=multi-user.target

7: Create a start.sh in /home/alfio:

#!/bin/sh
/usr/bin/java -jar alfio*.war -Xms512M -Xmx1024M > startup.log 2>&1 

8: Create /home/alfio/application.properties:

datasource.dialect=PGSQL
datasource.driver=org.postgresql.Driver
datasource.url=jdbc:postgresql://localhost:5432/alfio
datasource.username=alfio
datasource.password=<YOUR_POSTGRESQL_PASSWORD_HERE>
datasource.validationQuery=SELECT 1
spring.profiles.active=prod

9: To make sure the alfio user cannot log in, edit /etc/passwd and change /bin/bash (or /bin/sh) for the user alfio to /usr/sbin/nologin

10: Create an SSL certificate:

sudo apt install letsencrypt python3-certbot-nginx -y
sudo certbot --nginx -d reservation.yourdomain.church

11: Enable Alfio to run at boot:

sudo systemctl enable alfio
sudo systemctl start alfio

12: There should now be a startup.log in /home/alfio. Check it to find the initial password for the ‘admin’ user.

13: Open https://reservation.yourdomain.church/admin and log in with the user ‘admin’ and the password you just found. Change the password to something rediculously long and hard and unique & save it in a password manager (Apple Keychain, Macpass, Keepass, etc).

14: Congratulations, you have installed your own Alfio reservation system. Check the Alfio documentation on how to configure the rest, like an email server and events.