diyhosting/matrix.html

132 lines
6.5 KiB
HTML

<!DOCTYPE html>
<html lang=en>
<head>
<title>Matrix Synapse Server &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>Matrix Synapse Server</h1></header>
<nav></nav>
<main>
<img src="pix/matrix.svg" alt="Matrix Synapse Logo" class=titleimg>
<p>Matrix is easy-to-use, decentralized and encrypted private chat software.
Matrix is federated, meaning that with a Matrix account on any server, including your own, you can talk to any other Matrix account on the internet, similar to email.
Matrix also allows fully end-to-end encrypted group chats.
</p>
<p><strong>Synapse</strong> is the name of the default Matrix server. It is written in Python. While it is requires somewhat more system resources than <a href="xmpp.html">an XMPP server</a>, it makes up for that in being very accessible to non-technical users.</p>
<h2>Installation</h2>
<p>Synapse is not in the Debian package repositories by default, but we can easily add Matrix's repository including it:</p>
<pre><code>apt install -y lsb-release wget apt-transport-https
wget -O /usr/share/keyrings/matrix-org-archive-keyring.gpg https://packages.matrix.org/debian/matrix-org-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/matrix-org-archive-keyring.gpg] https://packages.matrix.org/debian/ $(lsb_release -cs) main" &gt; /etc/apt/sources.list.d/matrix-org.list</code></pre>
<p>After we update our packages lists, we will be able to install Synapse with <code>apt</code>.</p>
<pre><code>apt update
apt install matrix-synapse-py3</code></pre>
<p>When prompted, give your main domain name (not a subdomain). This will be the domain appended to your Matrix address, e.g. <code>@chad:landchad.net</code>.</p>
<h2>Nginx configuration</h2>
<p>Create an Nginx configuration file for Matrix, say <code>/etc/nginx/sites-available/matrix</code> and add the content below:
</p>
<pre><code>server {
server_name matrix.<strong>example.org</strong> ;
listen 80;
listen [::]:80;
location / {
proxy_pass http://localhost:8008;
}
location ~* ^(\/_matrix|\/_synapse\/client) {
proxy_pass http://localhost:8008;
proxy_set_header X-Forwarded-For $remote_addr;
client_max_body_size <strong>50M</strong> ;
}
location /.well-known/matrix/server {
return 200 '{"m.homeserver": {"base_url": "https://matrix.<strong>example.org</strong>"}}';
default_type application/json;
add_header Access-Control-Allow-Origin *;
}
}</code></pre>
<aside>
<p>Note the <code>client_max_body_size</code> variable. By default, Nginx caps the size of files it can transfer. We increase that to 50M if needed by Matrix. (Note however that both Matrix and Nginx have seperate settings for this and to raise it to something much larger, you will have to increase the value in both congfiguration files.)
</p>
</aside>
<p>Now let's enable the Nginx Matrix site and reload Nginx to make it active.</p>
<pre><code>ln -s /etc/nginx/sites-available/matrix /etc/nginx/sites-enabled
systemctl reload nginx</code></pre>
<h3>Encryption</h3>
<p>Obviously, we need to encrypt our <code>matrix</code> subdomain as well. Let's do that with certbot:</p>
<pre><code>certbot --nginx -d matrix.<strong>example.org</strong></code></pre>
<h2>Configuration</h2>
<h3>Read the config file</h3>
<p>
The configuration file for Matrix is in <code>/etc/matrix-synapse/homeserver.yaml</code>.
It is well documented and commented, so you can read about the settings, but let's change the essential ones here.
</p>
<p>
Make what changes you want and run <code>systemctl reload matrix-synapse</code> to make the system configuration active.
</p>
<h3>Create an administrator account</h3>
<p>If you allow open registration on your server in the configuration file, you can create an account through Element or another Matrix client, but you are probably going to want an official admin account to use.
To make one, simply run the following command, which will then give you several choices for creating a user, among which will be the ability to make it an admin.
</p>
<pre><code>register_new_matrix_user -c homeserver.yaml http://localhost:8008</code></pre>
<h2>Using Matrix with <img src="pix/element.svg" alt="Element Matrix logo">Element</h2>
<p>
There are many different <a href="https://matrix.org/clients/">clients</a> that can be used on desktops or phones to chat on your Matrix server, but the most popular and most widely vetted is <img src="pix/element.svg" alt="Element logo">Element.
</p>
<p>Get Element to access your Matrix server:</p>
<ul>
<li>Mobile:
<ul>
<li><a href="https://f-droid.org/packages/im.vector.app/">F-droid</a></li>
<li><a href="https://play.google.com/store/apps/details?id=im.vector.app">Google Play</a></li>
<li><a href="https://apps.apple.com/app/vector/id1083446067">Apple App Store</a></li>
</ul>
</li>
<li>Real computer:
<ul>
<li>GNU/Linux: You know how to install it.</li>
<li><a href="https://packages.riot.im/desktop/install/win32/x64/Element%20Setup.exe">Windows</a></li>
<li><a href="https://packages.riot.im/desktop/install/macos/Element.dmg">Mac</a></li>
</ul>
</li>
</ul>
<p>
Note also that Element has a web client (i.e. a version that can be accessed on your own website) that is also easy to install on an Nginx server,
although that will be covered in another article.
</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>