Dead Simple Prosody Chat Server

Prosody is a free and open source software that provides XMPP/Jabber server service for chat or instant messaging. It has multi-domain supports and other XMPP/Jabber features.

Let’s install it, configure it and use it. I’ll be using Ubuntu server 14.04 and Prosody from apt-get.

Upgrade the server and reboot:

[code lang=text]
sudo apt-get -y update
sudo apt-get -y upgrade
sudo reboot
[/code]

Please note that you may skip above steps if you know what you’re doing.

Install Prosody:

[code lang=text]
sudo apt-get -y install prosody
[/code]

That’s it. Installation is finished. Next is to create SSL certificates and do some basic configuration.

Create self-signed SSL certificate, valid for 10 years, and prepare it for Prosody. In this example I have created 1 set of cert for domain textng.com:

[code lang=text]
openssl req -new -x509 -newkey rsa:4096 -days 3650 -keyout textng.com.key -out textng.com.crt
openssl rsa -in textng.com.key -out textng.com.crt
chmod 640 *.key *.crt
sudo chown root.prosody *.key *.crt
sudo mv textng.com.* /etc/prosody/certs/
sudo ls -l /etc/prosody/certs/
[/code]

Repeat creating and preparing more self-signed SSL certificates when you need to. One set of SSL certificate for one domain.

Please note that file permissions, ownership, names and location are important.

Start working on Prosody config files, first the main config file prosody.cfg.lua:

[code lang=text]
cd /etc/prosody
sudo vi prosody.cfg.lua
[/code]

On prosody.cfg.lua, add admin XMPP/Jabber ID:

[code lang=text]
admins = { "admin@textng.com" }
[/code]

Still on prosody.cfg.lua, set to require encryption for client connection and server to server connection:

[code lang=text]
c2s_require_encryption = true
s2s_secure_auth = true
[/code]

Save the file and exit editor.

Next, configure domains. In this example I will configure Prosody to handle 2 domains: textng.com and itmn.co.id. I have previously created 2 sets of self-signed SSL certificates and copy them to /etc/prosody/certs.

Start working on domain config file, copy from example configuration:

[code lang=text]
sudo cp conf.avail/example.com.cfg.lua conf.d/textng.com.cfg.lua
[/code]

Find and replace every example.com with textng.com:

[code lang=text]
sudo sed -i 's/example.com/textng.com/g' conf.d/textng.com.cfg.lua
[/code]

Edit conf.d/textng.com.cfg.lua:

[code lang=text]
sudo vi conf.d/textng.com.cfg.lua
[/code]

On conf.d/textng.com.cfg.lua, enable it:

[code lang=text]
enabled = true
[/code]

Repeat the process to add more domains. One config file for one domain.

Restart Prosody and check the status:

[code lang=text]
sudo /etc/init.d/prosody restart
sudo prosodyctl status
sudo tail -f /var/log/prosody/prosody.log
[/code]

Add XMPP/Jabber ID for admin:

[code lang=text]
sudo prosodyctl adduser admin@textng.com
[/code]

Example of adding 2 more XMPP/Jabber IDs:

[code lang=text]
sudo prosodyctl adduser anton@textng.com
sudo prosodyctl adduser anton@itmn.co.id
[/code]

You may add as much XMPP/Jabber IDs as you want to.

Installation and basic configuration of Prosody is finished. You may try to login from XMPP/Jabber client softwares now.

2 thoughts on “Dead Simple Prosody Chat Server

Leave a Reply

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