Objective: Prosody - simple XMPP server for IM
XMPP is an IM protocol based on XML. It was developed in 1999. XMPP is defined in an open standard and uses an open systems approach of development and application, thus enabling everyone to implement application that would work with various other implementations.
To sum up, today one most important Jabber features are:
- secure instant messaging
- decentralization
Prerequisites
- a (prefferably) Debian droplet after initial setup. (Here) is a good tutorial on how to achieve it.
- few minutes of spare time.
What will we do?
- install Prosody
- install additional modules
- modify main prosody config file
- prepare virtualhost config section
1. install Prosody
Prosody developers provide their own repository. It is a good way to install Prosody in a secure manner, and keep up to date.
1.1 add the repository
echo deb http://packages.prosody.im/debian $(lsb_release -sc) main | sudo tee -a /etc/apt/sources.list
1.2 add Prosody key to local keyring, which is used to sign the packages:
wget https://prosody.im/files/prosody-debian-packages.key -O- | sudo apt-key add -
1.3 install Prosody, lua rocks manager and lua storage drivers.
aptitude update && aptitude install prosody-0.10 luarocks lua-zlib lua-dbi-common lua-dbi-sqlite3 -y
1.4 install required luarocks
luarocks install lua-zlib luaevent luasec luasocket
These additional rocks will provide us with forward secrecy. and stream compression.
2. install additional modules
Since Prosody - simple XMPP server for IM, installing Prosody modules is an easy task:
2.1 Clone prosody-modules reposiotory :
hg clone http://prosody-modules.googlecode.com/hg/ prosody-modules
and copy modules you want to enable to modules path.
In this repository there are many other modules, and all of them are well documented.
2.2 Find where Prosody is looking for modules.
At this time Prosody should be able to launch.
Command:
prosodyctl about
should return information about lua modules and Prosody directories.
It also tells where Prosody is looking for modules:
Plugin directories: /usr/local/lib/prosody/modules/
2.3 Decide which modules are worth enabling. Here are some of my suggestions:
2.3.1 XEP-0280: Message Carbons.
A quick explanation what XEP-0280 is would be:
when you are using several clients at the same time, all messages sent to and from your jid, goes to every conneted client.
Installation is a simple cp
command:
cp prosody-modules/mod_carbons/mod_carbons.lua /usr/local/lib/prosody/modules
Of course, if you have installed prosody in other way (like compiling from source) and have set different modules path, copy according to your destination(see 2.2). I am using default one.
2.3.2 XEP-0313: Message Archive Management
this extension stores some of your last conversations as an archive on server.
It helps achieve device synchronization. This is the module that allows clients to show you your previous conversations.
cp prosody-modules/mod_mam/mod_mam.lua /usr/local/lib/prosody/modules
2.3.3 mod_csi
This module is used mostly by mobile clients to indicate that client is inactive and do not want to get pushed things that are not urgent
cp prosody-modules/mod_csi/mod_csi.lua /usr/local/lib/prosody/modules
2.3.4 XEP-0198: Stream management
Tries to prevent message los when using an unreliable internet connection (often the case on mobile connections)
cp prosody-modules/mod_smacks/mod_smacks.lua /usr/local/lib/prosody/modules
2.3.5 mod_throttle_presence
This extension helps to save traffic on mobile connections. Since presence updates make up most of the traffic received by client, this module makes it possible to reduce
the amount of updates received by client.
cp prosody-modules/mod_throttle_presence/mod_throttle_presence.lua /usr/local/lib/prosody/modules
3. modify main prosody config file
Location of used config file can also be found by using
prosodyctl about
In my case it is:
/etc/prosody/prosody.cfg.lua
Now it is time to enable all the modules that we have just installed.
Find modules_enabled
section, and inside {...}
add:
"csi"; "throttle_presence"; "smacks"; "mam"; "carbons";
You can also uncomment “blocklist” to block contacts, “bosh” for chatrooms and “compression” for stream compression.
before virtualhost section add:
sql2 = { driver = "SQLite3", database = "prosody.sqlite" }
which will be used in a moment.
Remember to change the line:
authentication = "internal_hashed"
which will make prosody to hash and salt all passwords.
4. prepare virtualhost config section
4.1 Create VirtualHost
VirtualHost entry looks like that:
VirtualHost "example.com" ssl = { key = "/etc/prosody/certs/localhost.key"; certificate = "/etc/prosody/certs/localhost.crt"; } storage = { archive2 = "sql2"; } default_archive_policy = true max_archive_query_results = 50; Component "proxy.example.com" "proxy65" proxy65_address = "proxy.examplpe.com" Component "muc.example.com" "muc"
4.1.1 ssl
here both key and certificate are provided. You can generate one yourself, a selfsigned one by running:
openssl req -new -x509 -days 365 -nodes -out "localhost.crt" -newkey rsa:4096 -keyout "localhost.key"
4.1.2 set storage method for mod_mam.
Your last conversations will be saved in configured storage, sqlite database in this case. max_archive_query_results
represents the amount of messages that may be received by client in a single request.
4.1.3 proxy65 component enables you to share files
especially when one or both of client machines are behind a NAT
4.1.4 muc component enables creation of chatrooms
At this step your own Prosody instance is fully configured. Set SRV DNS record for XMPP to point on your server, or simply an A record and then juust add your user:
prosodyctl adduser UserName@serwer && prosodyctl start
and start chatting with your friends.
Hope you liked my article, in case you have any questions, feel free to comment! 😉