How to Setup an XMPP Server

XMPP is a free open standard for messaging and it has been around since 1999. It’s also decentralized. So it’s kind of like email but for instant messaging. Anyone can set up a server and anyone can use XMPP. There’s no central authoritative server that controls access. It can also be encrypted and difficult to eavesdrop on. This’s why a lot of people like it.

XMPP Logo

Below I’m going to show you how you can set up your own XMPP server on Linux using Prosody.

Setting up an XMPP server

Installation

My server runs Debian and Prosody is in the Debian repositories so getting started is very easy. Just install with:

apt-get install prosody

You might need to use sudo or login as root to run this command depending on how your system is set up.

XMPP Server Configuration

The prosody config file can be found at /etc/prosody/prosody.cfg.lua. I use nano to edit it but you can use whatever text editor you like.

nano /etc/prosody/prosody.cfg.lua

The first thing you will want to do is tell prosody who the admin will be. Find the “admins” setting in the config file and put in whatever your future xmpp address will be.

admins = { "username@example.org" }

Next find the spot that says “VirtualHost” and put in your server address. This is what mine looks like.

VirtualHost "xmpp.sysjolt.net

Multi-User Chats

If you want the ability to have chat rooms on your server you need to enable the multi-user chat module. To do this add the following to the config file.

Component "mcu.example.org" "muc"
    modules_enabled = { "muc_mam" }
    restrict_room_creation = "admin"

Keep in mind you have to have a separate subdomain for multi-user chat. I just used mcu.sysjolt.net.

File Transfers

To enable the ability to send pictures and files to each other you need to go to the config file and remove the comment code in front of “proxy65” to enable that feature.

Message Archiving

Another thing I do is turn down the amount of time the server holds messages. By default it is 7 days. It holds messages so that if you have more then 1 client they can sync your chat history as you switch between them.

I turn mine down to 3 days. No real reason it just seem like a good number to me.

archive_expires_after = "3d"

Certificates

You will most likely want server-to-server and client-to-server encryption. We can use certbot to help set that up.

If you don’t already have certbot you will need to install that first.

apt-get install certbot

Now we need to use certbot to get some free certificates from Let’s Encrypt.

certbot certonly -d chat.example.org

If you’re using Multi-User chats as well you will need a cert for that domain as well.

certbot certonly -d muc.example.org

Then ones we have the cert we can import it into Prosody.

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

Creating Users

Now you need to add users with this command. Start with yourself.

prosodyctl adduser username@example.org

Restart Prosody

To make all the config changes current we need to restart Prosody.

systemctl restart prosody

Manage Users

I have not found a good way to see who all is on the server. But if you loss track the users are listed at /var/lib/prosody/YOURURL/accounts.

Then you can use the prosodyctl command to manage them.

Now You Have Your Own XMPP Server

With that done your XMPP server is up and running. Now you just need to find a good XMPP client and have fun.

Something to keep in mind is some clients do not work as well with others. And I noticed OMEMO encryption failing between some clients. I have had my best luck with Conversations for Android and Gajim for Windows and Linux.

Leave a Reply

Your email address will not be published. Required fields are marked *