summaryrefslogtreecommitdiff
path: root/xmpp.html
blob: e3f9b69d618418e00e02b14b6d5f24361fedd852 (plain)
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
<!DOCTYPE html>
<html lang=en>
    <head>
        <title>XMPP Server (Prosody) &ndash; LandChad.net</title>
        <meta charset="utf-8"/>
        <link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
        <link rel='stylesheet' type='text/css' href='style.css'>
        <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel='alternate' type='application/rss+xml' title='Land Chad RSS' href='/rss.xml'>
    </head>
<body>
    <header><h1>XMPP Server (Prosody)</h1></header>
    <nav></nav>
    <main>

        <img class=titleimg src="pix/xmpp.svg" alt="XMPP Logo and Icon">

        <p>XMPP is a fantastically simple protocol that's usually used as a messenger.
        It's highly extensible,
        better than IRC,
        lighter and more decentralized and Matrix
        and Telegram and normie social media can't hold a candle to it.
        </p>

        <p>
        XMPP is so decentralized and extensible that there are many <em>different</em> XMPP servers.
        Here, let's set up an <a href="https://prosody.im/">Prosody</a> XMPP server.
        </p>

        <h2>Installation</h2>

        <p>
        Prosody is in the Debian repositories, so we can easily install it on our server with the following command:
        </p>

        <pre><code>apt install prosody</code></pre>


<h2>Configuration</h2>

<p>
The Prosody configuration file is in <code>/etc/prosody/prosody.cfg.lua</code>.
To set it all up, we will be changing several things.
</p>

<h3>Setting Admins</h3>

<p>
Let's go ahead and set who our admin(s) will be.
Find the line that says <code>admins = { }</code> and to this we can specify one or more server admins.
</p>

<pre><code># To add one admin:
admins = { "<strong>chad@example.org</strong>" }

# We can add more than one by separating them by commas. (This file is written in Lua.)
admins = { "<strong>chad@example.org</strong>", "<strong>chadmin@example.org</strong>" }</code></pre>

<p>
Note that we have not created these accounts yet, we will do this <a href=#user>below</a>.
</p>

<h3>Set the Server URL</h3>

<p>
Find the line <code>VirtualHost "localhost"</code> and replace <code>localhost</code> with your domain.
In our case, we will have <code>VirtualHost "example.org"</code>
</p>

<h3>Multi-User Chats</h3>

<p>
Most people will probably want the ability to have chats with more than two users.
This is easily enough to enable.
In the config file, add the following:
</p>

<pre><code>Component "<strong>chat.example.org</strong>" "muc"
    modules_enabled = { "muc_mam" }
    restrict_room_creation = "admin"</code></pre>

<p>
On the first line, you must have a separate subdomain for your multi-user chats.
I use the <code>chat.</code> subdomain, but some use <code>muc.</code>.
Anything if possible.
</p>

<p>
The second line is important because it prevents non-admins from creating and squatting rooms on your server.
The only situation where you might not want that is if you indend to open a general public chat system for people you don't know.
</p>

<aside>
<p>
Read more about the <code>muc</code> plugin on the Prosody documentation page <a href="https://prosody.im/doc/modules/mod_muc">here</a>.
</p>
</aside>

<h3>Enabling chat histories</h3>

<p>
By default, Prosody will send out messages received only to the first available clients.
That means that if you have your desktop client turned off and your cell phone receives a message, it will <em>not</em> be available to the desktop client when you start it.
</p>

<p>While this may be preferred in some cases, enable the MAM module (Message Archive Management) to have the server hold on messages and sync them to all clients.</p>

<p>
Within the <code>modules_enabled</code> block, you can uncomment the <code>mam</code> line to enable it.
You can see other settings for this module <a href="https://prosody.im/doc/modules/mod_mam">here</a> like, for example, how long a server should hold on to message histories for synching.
</p>

<p>
Note also that Prosody comes with the <code>carbons</code> activated module by default, which is related. This will send received messages to <em>all</em> active clients (your phone and desktop), although it will not save messages like MAM for clients not online or to be added later.
</p>

<h3>Other things to check</h3>

<p>Check the config file for other settings you might want to change.
For example, if you want to run a general public XMPP server, you can allow anyone to create an account by changing <code>allow_registration</code> to <code>true</code>.
</p>

<h2>Certificates</h2>

<p>
Obviously, we want to have client-to-server and server-to-server encryption.
Nowadays, use can use Certbot to generate certificates and use a convenient command below <code>prosodyctl</code> to import them.
</p>

<p>
<strong>If you have multi-user chat enabled, be sure to get a certificate for that subdomain as well.</strong>
Include the <code>--nginx</code> option assuming you have an Nginx server running.
</p>

<pre><code>certbot -d <strong>chat.example.org</strong> --nginx</code></pre>

<p>
Once you have the certificates for encryption, run the following to import them into Prosody.
</p>

<pre><code>prosodyctl --root cert import /etc/letsencrypt/live/</code></pre>

<p>
Note that you might get an error that a certificate has not been found if your <code>muc</code> subdomain and your main domain share a certificate.
It should still work, this is just notifying you that no specific
</p>


<p>
For user privacy, we will definitely want to install and enable encryption with OMEMO.
</p>

<h2 id=user>Creating users/admins manually</h2>

<p>
Let's manually create the admin user we prepared for above.
Note that you can indeed do this in your XMPP client if you have not disabled registration, but this is how it is done on the command line:
</p>

<pre><code>prosodyctl adduser <strong>chad@example.org</strong></code></pre>

<p>This will prompt you to create a password as well.</p>


<h2>Make changes active</h2>

<p>
With any system service, use <code>systemctl reload</code> or <code>systemctl restart</code> to make the new settings active:
</p>

<pre><code>systemctl restart prosody</code></pre>

<h2>Using your Server!</h2>

<p>
Once your server is set up, you just need an XMPP client to use your new and secure chat system.
</p>

<ul>
    <li>GNU/Linux: <a href="https://dino.im/">Dino</a> or <a href="https://gajim.org/">Gajim</a></li>
    <li>Windows: <a href="https://gajim.org/">Gajim</a> also runs on Windows.</li>
    <li>Android: <a href="https://conversations.im/">Conversations.im</a></li>
    <li>Mac/iOS: <a href="https://monal.im/">Monal IM</a> or <a href="https://siskin.im/">Siskin</a> for iOS alone</li>
    <li>command-line (GNU/Linux, MacOS, Windows): <a href="https://profanity-im.github.io/">Profanity</a></li>
    <li><a href="https://xmpp.org/software/clients.html">See a more complete list kept by XMPP</a></li>
</ul>

<p>
Install whichever of these clients you want on your computer or phone and you can log into your new XMPP server with the account you made.
Note that if you enabled public registration, anyone can create an account on your server through one of these clients.
</p>

<h3>Account addresses</h3>

<p>
XMPP account addressed look just like email addresses: <code><strong>username@example.org</strong></code>.
You can message any account on any XMPP server on the internet with that format.
</p>

<h3>Note on MUCs (multi-user chats)</h3>

<p>
Remember that MUCs are kept on a separate subdomain that we created and should've gotten a certificate for above, for example, <code><strong>chat.example.org</strong></code>.
Chatrooms are created and referred to in the following format: <code><strong>#chatroomname@chat.example.org</strong></code>.
</p>

    </main>
	<footer><a href="https://landchad.net">LandChad.net</a></br>Because Everyone should be an Internet LandChad.</br><a href="index.html"><li><img src="pix/chad.gif" alt="chad"></li></a><a href="rss.xml"><li><img src="pix/rss.svg" alt="RSS"></li></a><a href="donate-bitcoin.html"><li><img src="pix/btc.svg" alt="BTC"></li></a><a href="donate-monero.html"><li><img src="pix/xmr.svg" alt="XMR"></li></a><a href="https://github.com/lukesmithxyz/landchad"><li><img src="pix/git.svg" alt="Github"></li></a></footer>
</body>
</html>