Setting up Snac in OpenBSD

A simple, minimalistic microblogging ActivityPub instance that allows you to post in such of lightweight interface.

Features

  • Lightweight, minimal dependencies
  • Multiuser
  • Simple web interface
  • No database, javascript, or even cookies needed.
  • Supports unveil() in OpenBSD
  • Backend is completely written in C
  • Support FastCGI, Allowing setup with only OpenHTTPd

Configuring httpd.conf

Edit /etc/httpd.conf:

# $OpenBSD: httpd.conf,v 1.22 2020/11/04 10:34:18 denis Exp $

server "snac.example.com" {
	listen on * port 80

	location "/.well-known/acme-challenge/*" {
		root "/acme"
		request strip 2
	}

	location * {
		fastcgi socket tcp "127.0.0.1" 8001
	}

	connection { max request body 104857600 }
}

Replace snac.example.com with your hostname.

Save the file, Then enable and start httpd (as root):

# rcctl enable httpd
# rcctl start httpd

Get SSL Certificate with acme-client. Once successfully obtained SSL certs, Edit /etc/httpd.conf and add the following lines after listen on * port 80:

server "snac.example.com" {
	listen on * port 80
	listen on * tls port 443 # for TLS
	tls {
		certificate "/etc/ssl/snac.example.com.crt"
		key "/etc/ssl/private/snac.example.com.key"
	}

	location * {
		fastcgi socket tcp "127.0.0.1" 8001
	}

	connection { max request body 104857600 }
}

Replace snac.example.com with your hostname, and finally reload httpd by rcctl reload httpd and https should works.

Installation

Install required packages:

# pkg_add curl git nano

Clone the repository, then start installing.

$ git clone https://codeberg.org/grunfink/snac2
$ cd snac2
$ make
$ doas make install

Let's copy the examples/snac_openbsd to /etc/rc.d/, then start editing

# cp examples/snac_openbsd /etc/rc.d/snac
# chmod +x /etc/rc.d/snac
# nano /etc/rc.d/snac

Then you will see the code as the following:

#!/bin/ksh

daemon_args="httpd /PATH/TO/SNAC/BASEDIR"
daemon_logger="daemon.info"
daemon_user="SNACUSER"
daemon="/usr/local/bin/snac ${daemon_args}"

. /etc/rc.d/rc.subr

pexp="${daemon}.*"
rc_reload=NO
rc_bg=YES

rc_cmd $1

# this is an OpenBSD /etc/rc.d startup script. Edit and run as root:
#
# install snac_openbsd /etc/rc.d/snac
# rcctl enable snac
# rcctl start snac

Change /PATH/TO/SNAC/BASEDIR to /var/snac/data, and SNACUSER as snac

Save it by doing CTRL + S, Then close nano editor with CTRL + X.

Now, We will set up the user & the datadir.

# useradd -m -d /var/snac snac
# doas -u snac snac init /var/snac/data
Network address [127.0.0.1]:
Network port [8001]:
Host name: snac.example.com
URL prefix:
Admin email address (optional):
Done.

Replace snac.example.com with your domain.

Edit /var/snac/data/server.json (as root / snac user):

{
    "prefix": "",
    "address": "127.0.0.1",
    "port": 8001,
    "dbglevel": 0,
    "queue_retry_minutes": 2,
    "queue_retry_max": 10,
    "cssurls": [
        ""
    ],
    "max_timeline_entries": 128,
    "timeline_purge_days": 120,
    "local_purge_days": 0,
    "admin_account": "",
    "title": "",
    "short_description": "",
    "fastcgi": false,
    "layout": 2.7,
    "host": "snac.example.com",
    "admin_email": ""
}

Change "fastcgi": false to "fastcgi": true

Save the server.json file,

Now, create an user.

$ doas -u snac snac adduser /var/snac/data yourname
Creating RSA key...
Done.

User password is abcdefg1234567

Go to https://snac.example.com/yourname and continue configuring your user there.

Start the snac daemon, and visit your snac website.

# rcctl enable snac
# rcctl start snac