Setting up an XMPP Server

Thu 26 March 2015 by Eric Richter

This will be the first in a series of posts about XMPP, servers, clients, and other cool stuff. So to start this off, I will walk through the steps I took to set up COSI's XMPP server. There is a lot of XMPP server software available, and I will not cover most of them. This guide will use Prosody.

About XMPP

So what is XMPP? Before getting to the fun stuff, let's first take a look at what XMPP is, and why we should care about setting up a server. Formerly known as Jabber, XMPP is the eXtensible Message and Presence Protocol. In less fancy terms, it is a glorified instant messaging system on steroids. XMPP is at the core of many chat systems you may be familiar with. Facebook's chat is actually just XMPP wrapped with a fancier web interface, same with GTalk.

Okay, so it's a chat system, but how does it work? Let's say there exists a server at xmpp.lastprime.net. Each user on this server has a JID (Jabber ID), that looks like a email address, such as richteer@xmpp.lastprime.net. If a user wants to send a message to richteer@xmpp.lastprime.net, it would be send to the server xmpp.lastprime.net which will route it to the user richteer.

Well, what if I want to send messages to a user on another server, say xmpp.cslabs.clarkson.edu? Servers can pass messages to each other, provided they are configured to do so. So, if richteer@xmpp.lastprime.net wanted to send a message to richteer@xmpp.cslabs.clarkson.edu, the message would still be sent to the xmpp.lastprime.net server, who will pass the message to xmpp.cslabs.clarkson.edu, which will ultimately route it to richteer@xmpp.cslabs.clarkson.edu.

It sounds inefficient, going through so many layers of redirection, however this allows for better control of networks. This system allows a server on xmpp.lastprime.net to have its own set of users that can still communicate with the users on the Labs' server, without needing an account on both servers. Furthermore, if for some reason either side wishes to sever ties (compromised security, etc.), they can no longer elect to transfer messages between them, thus segmenting the user bases. The best use case for me personally, is to have my non-Clarkson friends on my server, and still be able to participate in the cosi chatroom without needing two clients/accounts logged in.

Future posts will cover setting up server-to-server connections.

About Prosody

Really quick, Prosody is a modular XMPP server written in Lua, and is the easiest to configure that I have found. The stock configuration is largely useable on its own, and editing it is as simple as editing Lua lists. It performs well, and I have noticed no load issues thus far. Therefore, it is satisfactory to use for my personal uses, and the uses of the labs. In comparison, other server software do not have as friendly configuration schemes, and the performance benefits they may have are marginal at best. (Take a look at an ejabberd config file)

Configuration

Assuming Prosody is installed (check your distro's package manager), open the /etc/prosody/prosody.cfg.lua file in your favorite editor (NOTE: This might be named slightly differently on other systems).

First, we need to define what this server will actually serve, that is, what is the name of the server. Towards the bottom of the sample configuration file there should be a line something like the following:

VirtualHost "localhost"

Change or copy this line to be:

VirtualHost "your.domainname.here"

This sets your server's host name that will be used in the latter half of the JIDs. Any other settings underneath a VirtualHost line will apply to only that host (as multiple can be served). Later, we will add SSL configurations to this region.

Next, look for the following line (it may not be included in the default configuration):

authentication = "internal_hashed"

If this line doesn't exist, or is set to anything other than internal_hashed change it to match. This sets the password storing scheme; by some default configs, Prosody will use plaintext. While this is not critical to the operation of the server, I cannot in good faith gloss over this terrible practice. More security settings will be covered in the future.

That's really all you need to configure to get a base system functional.

Running and Creating Users

If you installed Prosody from a package manager, it probably shipped with some scripts/service files or whatever for starting and stopping it (like service prosody start, or something). However, you can also start, stop, and interact with Prosody with prosodyctl. Creating a user can also be done by running prosodyctl adduser JID@your.domainname.here, and it will walk you through the process.

Other Notes

Obviously I glossed over a lot of other configuration options. Future posts will go into more detail on subsystems and other fun or recommended settings. Please be aware that running the default configuration is dangerous for production use, due to security concerns and whatnot.


Fork me on GitHub