Hosting an XMPP server with Prosody
Prosody is an open source (MIT) XMPP server written in Lua.
This guide focuses on Alpine Linux.
who uses prosody?
xmpp.is

One of the best public XMPP servers out there. Operated by the legends at unredacted.org.
disroot

XMPP server operated by disroot.org.
many small servers
Most personal XMPP servers run on Prosody. For example mine, Denshi’s, dacctal’s, JustZvan’s…
deploying
Install Prosody and other needed tools: apk add prosody certbot
your domain
You need a domain to run an XMPP server. I recommend njalla as a registrar.
setting up records
The record names I use here don’t really matter. You can use whatever you want.
We’re going to make 3 DNS records.
I run XMPP on forever2k38.net. You can also use a subdomain if you want to.
Add an record on the domain you want to host XMPP on and make it point to your VPS.
For forever2k38.net that record looks like this:

I use a CNAME record and make vps.forever2k38.net point to the actual VPS IP.
Next up you want a record for your file upload server. XMPP handles file uploads by having a separate HTTP server. Don’t worry, this is included in Prosody.

optional: muc
If you want to host MUCs on XMPP you need a MUC record.

TLS certificates
This is what we need certbot for.
Generate certificates for all your domains. For example:
certbot -d forever2k38.net
certbot -d muc.forever2k38.net # if you set up a MUC record
certbot -d share.forever2k38.net
configuring prosody
Edit /etc/prosody/prosody.cfg.lua.
VirtualHost
The first thing you need to do is edit your VirtualHosts.
Find this chunk and change localhost to your domain.
----------- Virtual hosts -----------
-- You need to add a VirtualHost entry for each domain you wish Prosody to serve.
-- Settings under each VirtualHost entry apply *only* to that host.
VirtualHost "localhost"
-- Prosody requires at least one enabled VirtualHost to function. You can
-- safely remove or disable 'localhost' once you have added another.
--VirtualHost "example.com"
For example: VirtualHost "forever2k38.net".
http file share
This is needed for file uploads to work.
Find this chunk, uncomment the Component line and set the proper domain:
---Set up a file sharing component
--Component "share.example.com" "http_file_share"
For example: Component "share.forever2k38.net" "http_file_share".
optional: MUC
To be able to create MUCs find this chunk and uncomment the Component line and set the proper domain:
---Set up a MUC (multi-user chat) room server on conference.example.com:
--Component "conference.example.com" "muc"
--- Store MUC messages in an archive and allow users to access it
--modules_enabled = { "muc_mam" }
I recommend uncommenting the modules_enabled line here if you want to store messages (especially useful for public MUCs).
certificates
Run /usr/bin/prosodyctl --root cert import /etc/letsencrypt/live to import the certificates you generated before.
To automate re-importing certificates on renewal create the file /etc/letsencrypt/renewal-hooks/deploy/prosody.sh with the following contents:
#!/bin/sh
/usr/bin/prosodyctl --root cert import /etc/letsencrypt/live
Make it executable: chmod +x /etc/letsencrypt/renewal-hooks/deploy/prosody.sh
You should be done now! If you have any questions, feel free to DM me on XMPP: forever2k38@forever2k38.net.