Setting up Prosody

Published on March 04, 2023

Installation

Install Prosody:

apk add prosody

We also need to install lua-unbound to use prosodyctl:

apk add lua-unbound@testing

Configuration

The configuration file for Prosody can be found in /etc/prosody/prosody.cnf.lua. Getting started with Prosody is relatively straight-forward. Just comment out the VirtualHost directive for "localhost", and add one for your domain instead:

--VirtualHost "localhost"
VirtualHost "example.com"

It is also possible to add more than one domain to your configuration.

If we already set up Let's Encrypt certificates, we can simply run the following command to import them:

/usr/bin/prosodyctl --root cert import /etc/letsencrypt/live

However, when renewing the certificates, it is a good idea to add this as a --deploy-hook to your renewal command, e.g.:

certbow renew --deply-hook "prosodyctl --root cert import /etc/letsencrypt/live"

The Prosody documentation has further information about setting up certificates as well as setting up Let's Encrypt with Prosody.

Start the service:

/etc/init.d/prosody start
rc-update add prosody

Create an XMPP account:

prosodyctl adduser me@example.com

Port forwarding

The Prosody documentation provides a list of ports used by Prosody that we need to set up using ufw:

ufw allow 5000/tcp
ufw allow 5222/tcp
ufw allow 5269/tcp
ufw allow 5280/tcp
ufw allow 5281/tcp
ufw allow 5347/tcp
ufw allow 5582/tcp

Setting up file sharing

Setting up file sharing is as simple as enabling the http_file_share component:

Component "xmpp-serve.example.com" "http_file_share"
http_file_share_expires_after = 3 * 24 * 60 * 60

In addition, you can set a number of parameters such as when the file expires (e.g. after three days). Here is a list of the available parameters.

If you have other domains available, then make sure to add the following to each of them below their VirtualHost directive to enable file sharing:

disco_items = {
        { "xmpp-serve.exmaple.com", "file sharing service" }
}

If you like my work or if my work has been useful to you in any way, then feel free to donate me a cup of coffee. Any donation is much appreciated!