gettie's space

How to set up a fully compliant XMPP server from scratch

2022-04-21

This is the English version of the guide I posted in the Linux User forum. This version also fixes some errors I made in the original version.

Introduction

In this guide I'll show you how to set up a fully compliant XMPP server step by step, from scratch. In contrast with other guides that explain the basics for the setup of a minimal server, this one aims to help new sysadmins to set up an XMPP server that complies up to 100% to the XMPP protocol.

There are a few XMPP servers you can pick from. This guide focuses on Prosody, which is one of the most popular options for an XMPP server, and it's quite flexible. Moreover, these instructions are given for servers that run Debian (or Debian-based distributions). If you use another distribution for your server, use the appropriate commands for your distribution and refer to the documentation of the software you are going to use.

What is XMPP

XMPP (also known as Jabber) is a protocol for instant messaging. Compared with other IM services, XMPP is decentralized with lots of servers running appropriate software than similar services which are based on a centralized server.

What is needed for the server

To set up the XMPP server, the following are required:

Installation and configuration of Prosody

To install Prosody, run sudo apt install prosody prosody-modules mercurial.

By running it, Prosody will be downloaded with some modules, which will be very useful later. mercurial will be used later to download some additional community modules that will be needed.

To download the community modules, run hg clone https://hg.prosody.im/prosody-modules/ prosody-modules.

(Personally, I have the prosody-modules directory at /usr/lib/prosody/modules/ for convenience. You can put it in whatever directory you want to.)

To set up prosody, edit the /etc/prosody/prosody.cfg.lua file as root with the text editor of your choice.

The following should be configured:

If the steps above are done, enable the prosody service and start it with the following commands:
sudo systemctl enable prosody
sudo systemctl start prosody

After starting Prosody, try to connect with your JID and your password to an XMPP client (I suggest using Dino on desktop and Conversations on Android). If you can connect to your server, it means that everything went alright. Otherwise, run the sudo prosodyctl check command. It's very helpful to troubleshoot any issues on Prosody.

If your server is functional, You might want to check compliance.conversations.im, where you can see your server's compliance with the XMPP protocol. It's suggested to make a testing account, which can also be useful later.

Upload server configuration

In order to upload files on the XMPP server, some things have to be configured first.

As you can see above, the upload component and the http_upload_external module were added in the configuration file. That module has a few implementations, as you can see here. In this guide, Prosody Filer (which is the implementation in Go) will be used, as it is the easiest to configure.

If there are no errors, restart Prosody by running sudo systemctl restart prosody. Then you can check if file uploading works from your XMPP client.

Turnserver configuration for audio and video calls

To improve your XMPP server a bit, you can easily set up a turnserver to be able to make and accept voice and video calls from friends.

You can restart Coturn and Prosody and try the calls function with another user, like the testing one, as I mentioned that earlier in the guide.

Finishing the setup

If the set up process didn't have any issues, it means that your server is ready and probably complies fully with the XMPP protocol. But XMPP's capabilities don't stop there, as you can improve your XMPP server with lots of extensions that you can try for your needs.