Setting up a Postmarks server for the Fediverse
Today I’m bringing my shared bookmarks to the Fediverse: @bookmarks@mark.apalrd.net
It’s a list of things that I like, basically. I hope to post links to lesser-known content creators or content that I really enjoy. The hope is that if you enjoy my content, that you might enjoy the things that I enjoy as well.
Hopefully this brings you things that The Algorithm normally might not.
So, anyway, how do you run the server?
Content⌗
Video⌗
Server⌗
I ran this in a LXC container based on the latest Debian (Trixie). I’m hosting it in my environment, you can host it on a VPS or your own environment, whatever you want.
Postmarks’s official docker image is using the extremely outdated Node.js 16, so I’ve used the oldest still supported version (18) to hopefully not break all this node shit, which has super picky version dependencies. It seems to be fine currently.
After doing the usual system upgrades (apt update && apt upgrade -y
), I install the tools we will need:
# Install nodesource's repo key to add node.js repositories
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /usr/share/keyrings/nodesource.gpg
chmod 644 /usr/share/keyrings/nodesource.gpg
# Add repo for Nodesourde node.js 18
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/nodesource.gpg] https://deb.nodesource.com/node_18.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list
# Apt update, since we added a repo
apt update
# Install packages we need
apt install nodejs npm git sudo -y
Postmarks⌗
You can find the official instructions Here. I’m not deviating from this, I’m adding to it
Now that the base software is installed, I’m going to git clone Postmarks into my web directory, change ownership to Mark, and then login as mark
to do the final configuration and testing.
# Create a new user for the service to run as
useradd -m -U mark
# Clone Postmarks into service location
cd /var
git clone https://github.com/ckolderup/postmarks
# Change ownership to mark
chown -R mark:mark postmarks
cd postmarks
Now we can login as mark: sudo -u mark bash
As mark, we need to create our .env
file. Here’s my file, choose your own passwords (and read the Postmarks readme for information on what these mean):
PUBLIC_BASE_URL=mark.apalrd.net
ADMIN_KEY=CorrectHorseBatteryStaple
SESSION_SECRET=CorrectHorseBatteryStaple
PORT=3000
HOST=::1
I’m using Caddy as a reverse proxy to handle TLS termination, HTTP/3, and cert management, among other things, so we will run Postmarks on its own bound to localhost only. As of this writing, this hasn’t merged into main yet, but it’s on my fork if you want to use my fork for now.
After the env file, you also need to copy account.json.example
into account.json
and edit it:
cp account.json.example account.json
nano account.json
The instructions for what to do are on the Postmarks github, but this is more customization and entirely optional.
And finally we need to run npm install: npm install
And you can use exit
to get out of the user mark
Systemd⌗
Here’s the systemd unit I am using (/etc/systemd/system/postmarks.service
):
[Unit]
Description=Postmarks bookmarking service
After=network-online.target
[Service]
User=mark
Group=mark
WorkingDirectory=/var/postmarks
ExecStart=npm run start
Restart=always
[Install]
WantedBy=multi-user.target
Then you can run:
systemctl daemon-reload
systemctl enable --now postmarks
and the service should be up!
Caddy⌗
I’m using Caddy for TLS termination, to provide HTTP/2 and HTTP/3, and automatic TLS. This isn’t a full guide to Caddy, but here’s a bit to get you started:
# Debian packages a very old version, so use Caddy's repos
# These instructions come straight from Caddy's site
# https://caddyserver.com/docs/install#debian-ubuntu-raspbian
sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https curl
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | tee /etc/apt/sources.list.d/caddy-stable.list
chmod o+r /usr/share/keyrings/caddy-stable-archive-keyring.gpg
chmod o+r /etc/apt/sources.list.d/caddy-stable.list
sudo apt update
sudo apt install caddy
And here is my Caddyfile (`/etc/caddy/Caddyfile):
# The Caddyfile is an easy way to configure your Caddy web server.
mark.apalrd.net {
# Reverse proxy mode
reverse_proxy localhost:3000
# Enable TLS but use self-signed cert
tls internal
}
And restart Caddy: systemctl restart caddy