diff options
| author | Luke Smith <luke@lukesmith.xyz> | 2022-03-29 14:32:07 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-03-29 14:32:07 +0000 |
| commit | 79b149b746fab1320cdc08a41ae57f01cbd49d03 (patch) | |
| tree | d13b96e46a12cea61e4ebaa169e822febd7d7fe3 /ejabberd.html | |
| parent | aade69af25d873cbdd60e21da9ff0f871c5fe199 (diff) | |
| parent | 8692c58648c6fb6fbedb10afd18938d14b7df362 (diff) | |
Merge pull request #126 from AleDenshi/master
added Ejabberd and Coturn tutorials
Diffstat (limited to 'ejabberd.html')
| -rw-r--r-- | ejabberd.html | 188 |
1 files changed, 188 insertions, 0 deletions
diff --git a/ejabberd.html b/ejabberd.html new file mode 100644 index 0000000..b758e77 --- /dev/null +++ b/ejabberd.html @@ -0,0 +1,188 @@ +<!DOCTYPE html> +<html lang=en> + <head> + <title>XMPP Server (ejabberd) – 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 (ejabberd)</h1></header> + <nav></nav> + <main> + + <img class=titleimg src="pix/xmpp.svg" alt="XMPP logo and icon"> + + <p> + <a href="https://ejabberd.im">Ejabberd</a> is a server for the XMPP protocol written in Erlang. + It's easier to configure and setup than <a href="xmpp.html">Prosody</a> due to having most of its modules built-in and pre-configured by default. + </p> + + <h2>Prerequisites</h2> + <h3>Subdomains</h3> + <p> + Ejabberd presumes that you have already created all the <strong>required and optional subdomains</strong> for its operation prior to running it. + </p> + + <p>Depending on the usecase, you may need any or all of the following domains for XMPP functionality:<p> + <ul> + <li><strong>example.org</strong> - Your XMPP hostname</li> + <li><strong>conference.example.org</strong> - For Multi User Chats (MUCs)</li> + <li><strong>upload.example.org</strong> - For file upload support</li> + <li><strong>proxy.example.org</strong> - For SOCKS5 proxy support</li> + <li><strong>pubsub.example.org</strong> - For publish-subscribe support</li> + </ul> + + <p>This guide will assume <strong>all these subdomains</strong> have been created.</p> + + <h2>Installation</h2> + <p>Ejabberd is available in the Debian repositories:</p> + <pre><code>apt install ejabberd</code></pre> + + <h2>Configuration</h2> + <p>The ejabberd server is configured in <code>/etc/ejabberd/ejabberd.yml</code>. Changes are only applied by restarting the ejabberd daemon in systemd:</p> + <pre><code>systemctl restart ejabberd</code></pre> + + <h3>Hostnames</h3> + <p>The <strong>XMPP hostname</strong> is specified in the <code>hosts</code> section of <code>ejabberd.yml</code>:</p> + + <pre><code>hosts: + - <strong>example.org</strong></code></pre> + + <h3>Certificates</h3> + <p>Unlike <a href="https://prosody.im">Prosody,</a> ejabberd doesn't come equipped with a script that can automatically copy over the relevant certificates to a directory where the ejabberd user can read them.</p> + + <p>One way of organizing certificates for ejabberd is to have them stored in <code>/etc/ejabberd/certs</code>, with each domain having a separate directory for both the fullchain cert and private key.</p> + + <p>Using certbot, this process can be easily automated with this one-liner:</p> + <pre><code>$DOMAIN=<strong>subdomain.example.org</strong> +certbot --nginx -d $DOMAIN certonly; mkdir /etc/ejabberd/certs/$DOMAIN; cp /etc/letsencrypt/live/$DOMAIN/fullchain.pem /etc/ejabberd/certs/$DOMAIN; cp /etc/letsencrypt/live/$DOMAIN/privkey.pem /etc/ejabberd/certs/$DOMAIN</code></pre> + + <p>This should be ran with your XMPP hostname <strong>(example.org)</strong> and repeated for all your desired subdomains.</p> + + <p>To enable the use of all these certificates in ejabberd, the following configuration is necessary:</p> + + <pre><code>certfiles: + - "/etc/ejabberd/certs/*/*.pem"</code></pre> + + <h3>Admin User</h3> + + <p>The <strong>admin user</strong> can be specified in <code>ejabberd.yml</code> under the <code>acl</code> section:</p> + + <pre><code>acl: + admin: + user: <strong>admin</strong></code></pre> + + <p>This would make <strong>admin@example.org</strong> the user with administrator privileges.</p> + + <h3>Message Archives</h3> + + <p>The ejabberd server supports keeping archives of messages through its <code>mod_mam</code> module. This can be enabled by uncommenting the following lines:</p> + + <pre><code>mod_mam: + assume_mam_usage: true + default: always</code></pre> + + <h2>Database</h2> + <h3>Why use a database?</h3> + <p>In the <code>mod_mam</code> section of the ejabberd config file, the following message is in comments:</p> + + <pre><code>mod_mam: + ## Mnesia is limited to 2GB, better to use an <strong>SQL backend</strong> + ## For small servers SQLite is a good fit and is very easy + ## to configure. Uncomment this when you have SQL configured: + ## <strong>db_type: sql</strong></code></pre> + + <p>As these comments imply, an <strong>SQL backend</strong> is strongly recommended if you wish to use your ejabberd server for anything more than just testing. Ejabberd supports <strong>MySQL, SQLite</strong> and <strong>PostgreSQL.</strong></p> + + <p>While all of those are suitable choices, the best database system to use is PostgreSQL. It's the same database backend used by <a href="peertube.html">PeerTube</a> and <a href="matrix.html">Matrix,</a> making it the most convenient option if you're already running those too.</p> + + <h3>Installing PostgreSQL</h3> + + <p>PostgreSQL is available in the Debian repositories:</p> + <pre><code>apt install postgresql</code></pre> + + <p>Start the PostgreSQL daemon to begin using it:</p> + <pre><code>systemctl start postgresql</code></pre> + + <h3>Creating the Database</h3> + <p>To create the database, first create a PostgreSQL user for ejabberd:</p> + + <pre><code>su -c "createuser --pwprompt ejabberd" postgres</code></pre> + + <p>Then, create the database and make <code>ejabberd</code> its owner:</p> + + <pre><code>su -c "psql -c 'CREATE DATABASE ejabberd OWNER ejabberd;'" postgres</code></pre> + + <h3>Importing Database Scheme</h3> + + <p>Ejabberd doesn't create the database scheme by default; It has to be imported into the database before use.</p> + + <pre><code>su -c "curl -s https://raw.githubusercontent.com/processone/ejabberd/master/sql/pg.sql | psql ejabberd" postgres</code></pre> + + <h3>Configuring ejabberd to use PostgreSQL</h3> + <p>Finally, add the following configuration to <code>ejabberd.yml</code>:</p> + + <pre><code>sql_type: pgsql +sql_server: "localhost" +sql_database: <strong>"ejabberd"</strong> +sql_username: <strong>"ejabberd"</strong> +sql_password: <strong>"psql_password"</strong></code></pre> + + <p>Once you've ensured your database name, username and password are all correct, enable SQL storage for <code>mod_mam</code>:</p> + + <pre><code>mod_mam: + ## (Other parameters) + db_type: <strong>sql</strong></code></pre> + + <h2>Using ejabberd</h2> + <h3>Registering the Admin User</h3> + <p>To begin using ejabberd, firstly start the ejabberd daemon:</p> + + <pre><code>systemctl restart ejabberd</code></pre> + + <p>Then, using <code>ejabberdctl</code> as the ejabberd user, register the admin user which is set in <code>ejabberd.yml</code>:</p> + + <pre><code>su -c "ejabberdctl register <strong>admin example.org password</strong>" ejabberd</code></pre> + + <p>This will create the user <strong>admin@example.org.</strong></p> + + <h3>Using the Web Interface</h3> + + <p>By default, ejabberd has a web interface accessible from <strong>http://example.org:5280/admin</strong>. When accessing this interface, you will be prompted for the admin credentials:</p> + + <img src="pix/ejabberd-login.jpg" height="260px"> + + <p>After signing in with the admin credentials, you will be able to manage your ejabberd server from this web interface:</p> + + <img src="pix/ejabberd-admin.jpg" height="300px"> + + <h2>TURN & STUN for Calls</h2> + + <p>Ejabberd supports the <strong>TURN</strong> and <strong>STUN</strong> protocols to allow internet users behind NATs to perform voice and video calls with other XMPP users.</p> + + <p>Firstly, setup a TURN and STUN server with <a href="coturn.html">Coturn,</a> using an <strong>authentication secret.</strong></p> + + <p>Then, edit <code>mod_stun_disco</code> to contain the appropriate information for your turnserver:</p> + + <pre><code> mod_stun_disco: + secret: <strong>"your_auth_secret"</strong> + services: + - + host: <strong>turn.example.org</strong> + type: stun + - + host: <strong>turn.example.org</strong> + type: turn</code></pre> + +<p>And with that, you've successfully setup your ejabberd XMPP server!</p> + + <hr> + <p><em>Written by <a href="https://denshi.org">Denshi.</a> Donate Monero <a href="https://denshi.org/donate.html">here</a> <a href="https://denshi.org/images/monero.jpg">[QR]</a></em></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="pix/btc.png"><li><img src="pix/btc.svg" alt="BTC"></li></a><a href="pix/xmr.png"><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> |
