Install Prosody XMPP Server on your Raspberry Pi

Created at 2016-09-09 Updated at 2016-11-02 Tag Linux / XMPP / Prosody / Raspberry Pi / Conversations / Jabber

Overview

Extensible Messaging and Presence Protocol (XMPP) is a set of free and open technologies for instant messaging, multi-party chat, voice and video chat, and more. It is a federated system, meaning that a user from one XMPP server can messaging someone with a different account on another server. This guide will show you how to setup your own XMPP chat service on Ubuntu or Debian using the Prosody XMPP server.

Use this guide to configure dynamic DNS on your raspberry pi if you would like to connect to a named domain. This is most likely essential if you are hosting your pi from your home.

Install

Prosody should already be in your distribution’s the repositories.

1
sudo apt-get install prosody

Generate you self-signed certs and keys:

1
2
3
4
5
6
sudo su
cd /etc/prosody/certs/
sudo openssl genrsa -out prosody.key 4096
sudo openssl req -new -sha256 -key prosody.key -out prosody.csr
sudo openssl x509 -req -sha256 -days 3650 -in prosody.csr -signkey prosody.key -out prosody.crt
exit

Next we plug in our SSH stuff to encrypt communicatinos on our server. We change this:

1
2
3
4
5
6
7
8
9
10
11
VirtualHost "example.com"
enabled = false -- Remove this line to enable this host
-- Assign this host a certificate for TLS, otherwise it would use the one
-- set in the global section (if any).
-- Note that old-style SSL on port 5223 only supports one certificate, and will always
-- use the global one.
ssl = {
key = "/etc/prosody/certs/example.com.key";
certificate = "/etc/prosody/certs/example.com.crt";
}

Into this:

1
2
3
4
5
VirtualHost "myIncredibleSiteName.no-ip.org"
ssl = {
key = "/etc/prosody/certs/prosody.key";
certificate = "/etc/prosody/certs/prosody.crt";
}

Enable multi-user chat, if desired:

1
Component "conference.example.no-ip.net" "muc"

Restart to make settings take effect:

1
sudo /etc/init.d/prosody restart

Next, we configure our first user.

1
prosodyctl adduser admin@example.ddns.net

Give the desired password at prompt.

Now foreward ports 5222 and 5269 on your router (Go ahead and foreward 5280 and 5281 as well if you want to upload and store files on your server).

To view information about your Prosody install, enter:

1
prosodyctl about

Conversations

An excellent free and open source XMPP client for Android is Conversations (also available at no cost on F-Droid

After installing the app, insert your user credentials.

Depending an the XMPP server that you create an account on, different functionality will be available to you. Here is a list of different servers and the XMPP extensions that they support


Right now we can add contacts and message with them. We can send any type of file, and it is routed and stored on the destination’s phone.

But what about group messaging? What about syncing message on different devices?


Go to Manage Accounts, select yours.

In upper right, check the Server info box.

We have a lot of cool stuff missing, it’s time we tried enabling it!

Modules

Here is a great list of public XMPP servers and the extensions that they support.

On our server, let’s enable all of the modules that the Conversations app supports.

First, install mercurial:

1
sudo apt-get install mercurial

Go into /usr/lib/prosody

1
hg clone https://hg.prosody.im/prosody-modules/ prosody-modules

In /etc/prosody/prosody.lua.config, add below the admin line plugin_paths = { "/usr/lib/prosody/prosody-modules" }

This is what my modules_enabled portion looks like now:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
modules_enabled = {
-- Generally required
"roster"; -- Allow users to have a roster. Recommended ;)
"saslauth"; -- Authentication for clients and servers. Recommended if you want to log in.
"tls"; -- Add support for secure TLS on c2s/s2s connections
"dialback"; -- s2s dialback support
"disco"; -- Service discovery
-- Not essential, but recommended
"private"; -- Private XML storage (for room bookmarks, etc.)
"vcard"; -- Allow users to set vCards
-- These are commented by default as they have a performance impact
--"privacy"; -- Support privacy lists
--"compression"; -- Stream compression (Debian: requires lua-zlib module to work)
-- Nice to have
"version"; -- Replies to server version requests
"uptime"; -- Report how long server has been running
"time"; -- Let others know the time here on this server
"ping"; -- Replies to XMPP pings with pongs
"pep"; -- Enables users to publish their mood, activity, playing music and more
"register"; -- Allow users to register on this server using a client and change passwords
-- Admin interfaces
"admin_adhoc"; -- Allows administration via an XMPP client that supports ad-hoc commands
--"admin_telnet"; -- Opens telnet console interface on localhost port 5582
-- HTTP modules
"bosh"; -- Enable BOSH clients, aka "Jabber over HTTP"
"http_files"; -- Serve static files from a directory over HTTP
-- Other specific functionality
"posix"; -- POSIX functionality, sends server to background, enables syslog, etc.
--"groups"; -- Shared roster support
--"announce"; -- Send announcement to all online users
--"welcome"; -- Welcome users who register accounts
--"watchregistrations"; -- Alert admins of registrations
--"motd"; -- Send a message to users when they log in
--"legacyauth"; -- Legacy authentication. Only used by some old clients and bots.
--
--external modules--
"carbons";
"mam";
"mam_archive";
"smacks";
"http";
"http_upload";
"http_muc_log";
"csi";
"privacy";
"blocking";
};
--HTTP STUFF-----
http_ports = { 5280 }
http_interfaces = { "*" }
https_ports = { 5281 }
https_interfaces = { "*" }
http_upload_file_size_limit = 1024 * 1024 * 20 --20MB
https_ssl = {
certificate = "/etc/prosody/certs/prosody.crt";
key = "/etc/prosody/certs/prosody.key";
}
--END HTTP STUFF------

Restart Prosody to enable changes:

sudo /etc/init.d/prosody restart

All my modules are enabled!

allModulesWorking

Site by Jackson Stokes

Hide