ChatMatrix: Difference between revisions
(Created page with "{{ContainerInfo |image = Juypter.png |Domain = [https://chat.flowerhouse.at chat.flowerhouse.at] |MAC = BE:B1:89:38:28:44 |IP = 192.168.88.19 |Privileged = No |OS = Debian Bullseye |RAM = 4096MB |Cores = 2 }} <p>The ChatMatrix-LXC is reachable under <syntaxhighlight lang="Bash" inline>192.168.88.19</syntaxhighlight> which is located in the ServerVLAN.</p> <p>The subdomain is [https://chat.flowerhouse.at chat.flowerhouse.at] which is handled by the ReverseProxy.</p>...") |
|||
(89 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
{{ContainerInfo | {{ContainerInfo | ||
|image = | |image = Matrix-logo.png | ||
|Domain = [https://chat.flowerhouse.at chat.flowerhouse.at] | |Domain = [https://chat.flowerhouse.at chat.flowerhouse.at] | ||
|MAC = BE:B1:89:38:28:44 | |MAC = BE:B1:89:38:28:44 | ||
Line 14: | Line 14: | ||
__TOC__ | __TOC__ | ||
== Basic Setup == | == Basic Setup == | ||
<p>Be up to date</p> | |||
<syntaxhighlight lang="console"> | |||
apt update && apt upgrade | |||
</syntaxhighlight> | |||
<p>Change timezone</p> | |||
<syntaxhighlight lang="console"> | |||
timedatectl set-timezone Europe/Berlin | |||
</syntaxhighlight> | |||
<p>Change locales to de_AT.UTF-8 for special characters</p> | |||
<syntaxhighlight lang="console"> | |||
dpkg-reconfigure locales | |||
</syntaxhighlight> | |||
=== Installation === | === Installation === | ||
<p>Install required packages</p> | <p>Install required packages</p> | ||
<syntaxhighlight lang="console"> | <syntaxhighlight lang="console"> | ||
apt install python3-pip | apt install -y lsb-release wget apt-transport-https | ||
</syntaxhighlight> | |||
<p>Add repository</p> | |||
<syntaxhighlight lang="console" line> | |||
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" | tee /etc/apt/sources.list.d/matrix-org.list | |||
apt update | |||
</syntaxhighlight> | |||
<p>Install matrix-synapse</p> | |||
<syntaxhighlight lang="console"> | |||
apt install matrix-synapse-py3 | |||
</syntaxhighlight> | |||
<p>Check status</p> | |||
<syntaxhighlight lang="console"> | |||
systemctl status matrix-synapse | |||
</syntaxhighlight> | |||
=== Postgres database === | |||
<p>Install required packages</p> | |||
<syntaxhighlight lang="console"> | |||
apt install libpq5 postgresql | |||
</syntaxhighlight> | |||
<p>Open Postgres console</p> | |||
<syntaxhighlight lang="console"> | |||
su - postgres | |||
</syntaxhighlight> | |||
<p>Create user for matrix-synapse</p> | |||
<syntaxhighlight lang="console"> | |||
createuser --pwprompt synapse_user | |||
</syntaxhighlight> | |||
<p>Create database for matrix-synapse</p> | |||
<syntaxhighlight lang="console"> | |||
createdb --encoding=UTF8 --locale=C --template=template0 --owner=synapse_user synapse | |||
</syntaxhighlight> | |||
<p>Exit Postgres console</p> | |||
<syntaxhighlight lang="console"> | |||
exit | |||
</syntaxhighlight> | |||
<p>Edit matrix-synapse configuration file</p> | |||
<syntaxhighlight lang="console"> | |||
nano /etc/matrix-synapse/homeserver.yaml | |||
</syntaxhighlight> | |||
<p>Edit the database entry</p> | |||
<syntaxhighlight lang="console" line> | |||
database: | |||
name: psycopg2 | |||
args: | |||
user: synapse_user | |||
password: <pass> | |||
database: synapse | |||
host: localhost | |||
cp_min: 5 | |||
cp_max: 10 | |||
</syntaxhighlight> | |||
<p>Check if it works</p> | |||
<syntaxhighlight lang="console"> | |||
systemctl restart matrix-synapse | |||
systemctl status matrix-synapse | |||
</syntaxhighlight> | |||
=== Setting up reverse proxy === | |||
<p>NGINX Proxy Manager configuration without exposing admin API</p> | |||
<syntaxhighlight lang="console" line> | |||
Details: | |||
Scheme: http | |||
Forward Hostname / IP: 192.168.88.19 | |||
Port: 80 | |||
Custom Locations: | |||
location: ~ ^(/_matrix|/_synapse/client) | |||
Scheme: http | |||
Forward Hostname / IP: 192.168.88.19 | |||
Port: 8008 | |||
Advanced: | |||
listen 8448 ssl http2 default_server; | |||
listen [::]:8448 ssl http2 default_server; | |||
server_name matrix.flowerhouse.at; | |||
</syntaxhighlight> | |||
<p>If you want to expose admin api change location</p> | |||
<syntaxhighlight lang="json"> | |||
location: ~ ^(/_matrix|/_synapse) | |||
</syntaxhighlight> | |||
<p>Check if federation configuration is correct: https://federationtester.matrix.org/</p> | |||
=== .well-known === | |||
<p>NGINX Proxy Manager configuration without exposing admin API</p> | |||
<syntaxhighlight lang="console" line> | |||
Details: | |||
Scheme: http | |||
Forward Hostname / IP: 192.168.88.19 | |||
Port: 80 | |||
Custom Locations: | |||
location: ~ ^(/_matrix|/_synapse/client) | |||
Scheme: http | |||
Forward Hostname / IP: 192.168.88.19 | |||
Port: 8008 | |||
Advanced: | |||
listen 8448 ssl http2 default_server; | |||
listen [::]:8448 ssl http2 default_server; | |||
server_name matrix.flowerhouse.at; | |||
</syntaxhighlight> | |||
=== Add User === | |||
<syntaxhighlight lang="console"> | |||
register_new_matrix_user -c /etc/matrix-synapse/homeserver.yaml http://localhost:8008 | |||
</syntaxhighlight> | |||
=== Optional === | |||
==== Configure puppeting ==== | |||
<p>Install required packages</p> | |||
<syntaxhighlight lang="console"> | |||
apt install pip git pwgen | |||
</syntaxhighlight> | |||
<p>Activate synapse virtual enviroment</p> | |||
<syntaxhighlight lang="console" line> | |||
cd /opt/venvs/matrix-synapse | |||
source ./bin/activate | |||
</syntaxhighlight> | |||
<p>Install packages</p> | |||
<syntaxhighlight lang="console" line> | |||
pip install git+https://github.com/devture/matrix-synapse-shared-secret-auth | |||
deactivate | |||
</syntaxhighlight> | |||
<p>Generate shared secret</p> | |||
<syntaxhighlight lang="console"> | |||
pwgen -s 128 1 | |||
</syntaxhighlight> | |||
<p>Edit configuration and add [https://github.com/devture/matrix-synapse-shared-secret-auth#configuring configuration]</p> | |||
<syntaxhighlight lang="console"> | |||
nano /etc/matrix-synapse/homeserver.yaml | |||
</syntaxhighlight> | |||
<p>General information about [https://docs.mau.fi/bridges/general/double-puppeting.html puppeting]</p> | |||
=== Administration === | |||
Administration-Tools: | |||
* https://github.com/Awesome-Technologies/synapse-admin (WebUI) | |||
* https://github.com/JOJ0/synadm (Console) | |||
Or make API-Request with curl | |||
== Install Bridges == | |||
<p>ffmpeg is needed to support media files</p> | |||
<syntaxhighlight lang="console"> | |||
apt install ffmpeg | |||
</syntaxhighlight> | |||
=== WhatsApp === | |||
==== Installation ==== | |||
<p>Create user for mautrix-whatsapp</p> | |||
<syntaxhighlight lang="console"> | |||
adduser --system mautrix-whatsapp --home /opt/mautrix-whatsapp | |||
</syntaxhighlight> | |||
<p>Enter user folder</p> | |||
<syntaxhighlight lang="console" line> | |||
cd /opt/mautrix-whatsapp | |||
</syntaxhighlight> | |||
<p>Download binary from https://github.com/mautrix/whatsapp/releases</p> | |||
<p>Rename binary</p> | |||
<syntaxhighlight lang="console"> | |||
mv mautrix-whatsapp-amd64 mautrix-whatsapp | |||
</syntaxhighlight> | |||
==== Create database ==== | |||
<p>Open Postgres console</p> | |||
<syntaxhighlight lang="console"> | |||
su - postgres | |||
</syntaxhighlight> | |||
<p>Create user for mautrix-whatsapp</p> | |||
<syntaxhighlight lang="console"> | |||
createuser --pwprompt whatsapp_user | |||
</syntaxhighlight> | |||
<p>Create database for mautrix-whatsapp</p> | |||
<syntaxhighlight lang="console"> | |||
createdb --encoding=UTF8 --locale=C --template=template0 --owner=whatsapp_user whatsapp | |||
</syntaxhighlight> | |||
<p>Exit Postgres console</p> | |||
<syntaxhighlight lang="console"> | |||
exit | |||
</syntaxhighlight> | |||
==== Configuration ==== | |||
<p>Create and paste config file: [[mautrix-whatsapp-config.yaml]]</p> | |||
<syntaxhighlight lang="console"> | |||
nano config.yaml | |||
</syntaxhighlight> | |||
<p>Modify permissions</p> | |||
<syntaxhighlight lang="console"> | |||
chmod 755 mautrix-whatsapp | |||
</syntaxhighlight> | |||
<p>Generate the appservice registration file</p> | |||
<syntaxhighlight lang="console"> | |||
./mautrix-whatsapp -g | |||
</syntaxhighlight> | |||
<p>Modify permissions</p> | |||
<syntaxhighlight lang="console"> | |||
chmod 555 registration.yaml | |||
</syntaxhighlight> | |||
<p>Edit matrix-synapse configuration file</p> | |||
<syntaxhighlight lang="console"> | |||
nano /etc/matrix-synapse/homeserver.yaml | |||
</syntaxhighlight> | |||
<p>To register WhatsApp add following lines</p> | |||
<syntaxhighlight lang="console" line> | |||
app_service_config_files: | |||
- /opt/mautrix-whatsapp/registration.yaml | |||
</syntaxhighlight> | |||
<p>Restart matrix-synapse</p> | |||
<syntaxhighlight lang="console"> | |||
systemctl restart matrix-synapse | |||
</syntaxhighlight> | |||
<p>Check if bridge works</p> | |||
<syntaxhighlight lang="console"> | |||
./mautrix-whatsapp | |||
</syntaxhighlight> | |||
==== systemd service ==== | |||
<p>Create systemd service file and copy from [https://docs.mau.fi/bridges/go/setup.html?bridge=whatsapp#systemd-service service]</p> | |||
<syntaxhighlight lang="console"> | |||
nano /etc/systemd/system/mautrix-whatsapp.service | |||
</syntaxhighlight> | |||
<p>Apply changes</p> | |||
<syntaxhighlight lang="console"> | |||
systemctl daemon-reload | |||
</syntaxhighlight> | |||
<p>Start and check status</p> | |||
<syntaxhighlight lang="console" line> | |||
systemctl start mautrix-whatsapp | |||
systemctl status mautrix-whatsapp | |||
</syntaxhighlight> | |||
<p>Enable autostart</p> | |||
<syntaxhighlight lang="console"> | |||
systemctl enable mautrix-whatsapp | |||
</syntaxhighlight> | |||
=== Signal === | |||
==== Install Bridge ==== | |||
<p>Create user for mautrix-signal</p> | |||
<syntaxhighlight lang="console"> | |||
adduser --system mautrix-signal --home /opt/mautrix-signal | |||
usermod -aG signald mautrix-signal | |||
</syntaxhighlight> | |||
<p>Enter user folder</p> | |||
<syntaxhighlight lang="console"> | |||
cd /opt/mautrix-signal | |||
</syntaxhighlight> | |||
<p>Download binary from https://github.com/mautrix/signal/releases</p> | |||
<p>Rename binary</p> | |||
<syntaxhighlight lang="console"> | |||
mv mautrix-signal-amd64 mautrix-signal | |||
</syntaxhighlight> | |||
==== Create database ==== | |||
<p>Open Postgres console</p> | |||
<syntaxhighlight lang="console"> | |||
su - postgres | |||
</syntaxhighlight> | |||
<p>Create user for mautrix-whatsapp</p> | |||
<syntaxhighlight lang="console"> | |||
createuser --pwprompt signal_user | |||
</syntaxhighlight> | |||
<p>Create database for mautrix-whatsapp</p> | |||
<syntaxhighlight lang="console"> | |||
createdb --encoding=UTF8 --locale=C --template=template0 --owner=signal_user signal | |||
</syntaxhighlight> | |||
<p>Exit Postgres console</p> | |||
<syntaxhighlight lang="console"> | |||
exit | |||
</syntaxhighlight> | |||
==== Configuration ==== | |||
<p>Copy configuration file and edit...</p> | |||
<syntaxhighlight lang="console"> | |||
cp example-config.yaml config.yaml | |||
</syntaxhighlight> | |||
<p>Modify permissions</p> | |||
<syntaxhighlight lang="console"> | |||
chmod 755 mautrix-signal | |||
</syntaxhighlight> | |||
<p>Generate the appservice registration file</p> | |||
<syntaxhighlight lang="console"> | |||
./mautrix-signal -g | |||
</syntaxhighlight> | |||
<p>Modify permissions</p> | |||
<syntaxhighlight lang="console"> | |||
chmod 555 registration.yaml | |||
</syntaxhighlight> | |||
<p>Edit matrix-synapse configuration file</p> | |||
<syntaxhighlight lang="console"> | |||
nano /etc/matrix-synapse/homeserver.yaml | |||
</syntaxhighlight> | |||
<p>To register mautrix-signal add following lines</p> | |||
<syntaxhighlight lang="console" line> | |||
app_service_config_files: | |||
- /opt/mautrix-signal/registration.yaml | |||
</syntaxhighlight> | |||
<p>Restart matrix-synapse</p> | |||
<syntaxhighlight lang="console"> | |||
systemctl restart matrix-synapse | |||
</syntaxhighlight> | |||
<p>Check if bridge works</p> | |||
<syntaxhighlight lang="console"> | |||
./mautrix-signal | |||
</syntaxhighlight> | |||
==== systemd service ==== | |||
<p>Create systemd service file and copy from [https://docs.mau.fi/bridges/python/setup.html?bridge=signal service]</p> | |||
<syntaxhighlight lang="console"> | |||
nano /etc/systemd/system/mautrix-signal.service | |||
</syntaxhighlight> | |||
<p>Apply changes</p> | |||
<syntaxhighlight lang="console"> | |||
systemctl daemon-reload | |||
</syntaxhighlight> | |||
<p>Start and check status</p> | |||
<syntaxhighlight lang="console" line> | |||
systemctl start mautrix-signal | |||
systemctl status mautrix-signal | |||
</syntaxhighlight> | |||
<p>Enable autostart</p> | |||
<syntaxhighlight lang="console"> | |||
systemctl enable mautrix-signal | |||
</syntaxhighlight> | |||
=== Telegram === | |||
==== Installation ==== | |||
<p>Create user for bridge</p> | |||
<syntaxhighlight lang="console"> | |||
adduser --system mautrix-telegram --home /opt/mautrix-telegram | |||
</syntaxhighlight> | |||
<p>Go to directory</p> | |||
<syntaxhighlight lang="console"> | |||
cd /opt/mautrix-telegram | |||
</syntaxhighlight> | |||
<p>Create virtual environment</p> | |||
<syntaxhighlight lang="console"> | |||
virtualenv -p /usr/bin/python3 . | |||
</syntaxhighlight> | |||
<p>Activate virtual environment</p> | |||
<syntaxhighlight lang="console"> | |||
source ./bin/activate | |||
</syntaxhighlight> | |||
<p>Install signal bridge</p> | |||
<syntaxhighlight lang="console"> | |||
pip install --upgrade mautrix-telegram[all] | |||
</syntaxhighlight> | |||
==== Create database ==== | |||
<p>Open Postgres console</p> | |||
<syntaxhighlight lang="console"> | |||
su - postgres | |||
</syntaxhighlight> | |||
<p>Create user for mautrix-whatsapp</p> | |||
<syntaxhighlight lang="console"> | |||
createuser --pwprompt telegram_user | |||
</syntaxhighlight> | |||
<p>Create database for mautrix-whatsapp</p> | |||
<syntaxhighlight lang="console"> | |||
createdb --encoding=UTF8 --locale=C --template=template0 --owner=telegram_user telegram | |||
</syntaxhighlight> | |||
<p>Exit Postgres console</p> | |||
<syntaxhighlight lang="console"> | |||
exit | |||
</syntaxhighlight> | |||
==== Configuration ==== | |||
<p>Copy configuration file and edit...</p> | |||
<syntaxhighlight lang="console"> | |||
cp example-config.yaml config.yaml | |||
</syntaxhighlight> | |||
<p>Generate access file</p> | |||
<syntaxhighlight lang="console"> | |||
python -m mautrix_telegram -g | |||
</syntaxhighlight> | |||
<p>Set permissions</p> | |||
<syntaxhighlight lang="console"> | |||
chown -R mautrix-telegram:root ../mautrix-telegram/ | |||
</syntaxhighlight> | |||
<p>Edit matrix-synapse configuration file</p> | |||
<syntaxhighlight lang="console"> | |||
nano /etc/matrix-synapse/homeserver.yaml | |||
</syntaxhighlight> | |||
<p>To register WhatsApp add following lines</p> | |||
<syntaxhighlight lang="console" line> | |||
app_service_config_files: | |||
- /opt/mautrix-telegram/registration.yaml | |||
</syntaxhighlight> | |||
<p>Restart matrix-synapse</p> | |||
<syntaxhighlight lang="console"> | |||
systemctl restart matrix-synapse | |||
</syntaxhighlight> | |||
<p>Check if bridge works</p> | |||
<syntaxhighlight lang="console"> | |||
python -m mautrix_telegram | |||
</syntaxhighlight> | |||
==== systemd service ==== | |||
<p>Create systemd service file and copy from [https://docs.mau.fi/bridges/python/setup.html?bridge=telegram#systemd-service service]</p> | |||
<syntaxhighlight lang="console"> | |||
nano /etc/systemd/system/mautrix-telegram.service | |||
</syntaxhighlight> | |||
<p>Apply changes</p> | |||
<syntaxhighlight lang="console"> | |||
systemctl daemon-reload | |||
</syntaxhighlight> | |||
<p>Start and check status</p> | |||
<syntaxhighlight lang="console" line> | |||
systemctl start mautrix-telegram | |||
systemctl status mautrix-telegram | |||
</syntaxhighlight> | |||
<p>Enable autostart</p> | |||
<syntaxhighlight lang="console"> | |||
systemctl enable mautrix-telegram | |||
</syntaxhighlight> | |||
=== IRC === | |||
==== Installation ==== | |||
<p>Create user for bridge</p> | |||
<syntaxhighlight lang="console"> | |||
adduser --system mautrix-irc --home /opt/mautrix-irc | |||
</syntaxhighlight> | |||
<p>Go to directory</p> | |||
<syntaxhighlight lang="console"> | |||
cd /opt/mautrix-irc | |||
</syntaxhighlight> | |||
<p>Create virtual environment</p> | |||
<syntaxhighlight lang="console"> | |||
virtualenv -p /usr/bin/python3 . | |||
</syntaxhighlight> | |||
<p>Activate virtual environment</p> | |||
<syntaxhighlight lang="console"> | |||
source ./bin/activate | |||
</syntaxhighlight> | |||
<p>Install heisenbridge</p> | |||
<syntaxhighlight lang="console"> | |||
pip install --upgrade heisenbridge[all] | |||
</syntaxhighlight> | |||
<p>Generate access file</p> | |||
<syntaxhighlight lang="console"> | |||
python -m heisenbridge -c /opt/mautrix-irc/registration.yaml --generate | |||
</syntaxhighlight> | |||
<p>Set permissions</p> | |||
<syntaxhighlight lang="console"> | |||
chown -R mautrix-irc:root ../mautrix-irc/ | |||
</syntaxhighlight> | |||
<p>Edit matrix-synapse configuration file</p> | |||
<syntaxhighlight lang="console"> | |||
nano /etc/matrix-synapse/homeserver.yaml | |||
</syntaxhighlight> | |||
<p>To register WhatsApp add following lines</p> | |||
<syntaxhighlight lang="console" line> | |||
app_service_config_files: | |||
- /opt/mautrix-irc/registration.yaml | |||
</syntaxhighlight> | |||
<p>Restart matrix-synapse</p> | |||
<syntaxhighlight lang="console"> | |||
systemctl restart matrix-synapse | |||
</syntaxhighlight> | |||
<p>Check if bridge works</p> | |||
<syntaxhighlight lang="console"> | |||
python -m heisenbridge -c /opt/mautrix-irc/registration.yaml | |||
</syntaxhighlight> | |||
<p>If no .well-known file is configured, startup may take a few minutes</p> | |||
==== systemd service ==== | |||
<p>Create systemd service file and copy from [[mautrix-irc.service]]</p> | |||
<syntaxhighlight lang="console"> | |||
nano /etc/systemd/system/mautrix-irc.service | |||
</syntaxhighlight> | |||
<p>Apply changes</p> | |||
<syntaxhighlight lang="console"> | |||
systemctl daemon-reload | |||
</syntaxhighlight> | |||
<p>Start and check status</p> | |||
<syntaxhighlight lang="console" line> | |||
systemctl start mautrix-irc | |||
systemctl status mautrix-irc | |||
</syntaxhighlight> | |||
<p>Enable autostart</p> | |||
<syntaxhighlight lang="console"> | |||
systemctl enable mautrix-irc | |||
</syntaxhighlight> | |||
==== Configuration ==== | |||
<p>This bridge is not configured with an config file but via the bot chat.</p> | |||
<p>The first person chatting with the bot will automatically be set as the admin.</p> | |||
<p>Set mediaurl</p> | |||
<syntaxhighlight lang="console"> | |||
MEDIAURL https://matrix.flowerhouse.at | |||
</syntaxhighlight> | |||
== Install Element WebClient == | |||
<p>Install webserver</p> | |||
<syntaxhighlight lang="console"> | |||
apt install apache2 | |||
</syntaxhighlight> | |||
<p>Go to directory</p> | |||
<syntaxhighlight lang="console"> | |||
cd /var/www | |||
</syntaxhighlight> | |||
<p>Download binary from: https://github.com/vector-im/element-web/releases/</p> | |||
<p>Untar and rename</p> | |||
<syntaxhighlight lang="console" line> | |||
tar -xvf element-v1.11.1.tar.gz | |||
mv element-v1.11.1 element | |||
rm element-v1.11.1.tar.gz | |||
</syntaxhighlight> | |||
<p>Configure host</p> | |||
<syntaxhighlight lang="console"> | |||
nano /etc/apache2/sites-available/element.conf | |||
</syntaxhighlight> | |||
<p>Add to file</p> | |||
<syntaxhighlight lang="console" line> | |||
<VirtualHost *:80> | |||
DocumentRoot /var/www/element | |||
<Directory /var/www/element> | |||
AllowOverride All | |||
Order Allow,Deny | |||
Allow from All | |||
</Directory> | |||
ErrorLog /var/log/apache2/element_error.log | |||
</VirtualHost> | |||
</syntaxhighlight> | |||
<p>Activate new site</p> | |||
<syntaxhighlight lang="console"> | |||
ln -s /etc/apache2/sites-available/element.conf /etc/apache2/sites-enabled/element.conf | |||
</syntaxhighlight> | |||
<p>To access via the IP-Address of the server</p> | |||
<syntaxhighlight lang="console"> | |||
rm /etc/apache2/sites-enabled/000-default.conf | |||
</syntaxhighlight> | |||
<p>Configure apache to show pretty URL pathes</p> | |||
<syntaxhighlight lang="console"> | |||
a2enmod rewrite | |||
</syntaxhighlight> | |||
<p>Restart webserver</p> | |||
<syntaxhighlight lang="console"> | |||
service apache2 restart | |||
</syntaxhighlight> | |||
<p>Create config file</p> | |||
<syntaxhighlight lang="console"> | |||
cd element | |||
cp config.sample.json config.json | |||
</syntaxhighlight> | |||
<p>Edit config file</p> | |||
<syntaxhighlight lang="console"> | |||
nano config.json | |||
</syntaxhighlight> | </syntaxhighlight> |
Latest revision as of 15:22, 16 March 2024
IP: | 192.168.88.19 |
---|---|
MAC: | BE:B1:89:38:28:44 |
Domain: | chat.flowerhouse.at |
OS: | Debian Bullseye |
---|---|
RAM: | 4096MB |
Cores: | 2 |
Privileged: | No |
The ChatMatrix-LXC is reachable under 192.168.88.19
which is located in the ServerVLAN.
The subdomain is chat.flowerhouse.at which is handled by the ReverseProxy.
Basic Setup
Be up to date
apt update && apt upgrade
Change timezone
timedatectl set-timezone Europe/Berlin
Change locales to de_AT.UTF-8 for special characters
dpkg-reconfigure locales
Installation
Install required packages
apt install -y lsb-release wget apt-transport-https
Add repository
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" | tee /etc/apt/sources.list.d/matrix-org.list
apt update
Install matrix-synapse
apt install matrix-synapse-py3
Check status
systemctl status matrix-synapse
Postgres database
Install required packages
apt install libpq5 postgresql
Open Postgres console
su - postgres
Create user for matrix-synapse
createuser --pwprompt synapse_user
Create database for matrix-synapse
createdb --encoding=UTF8 --locale=C --template=template0 --owner=synapse_user synapse
Exit Postgres console
exit
Edit matrix-synapse configuration file
nano /etc/matrix-synapse/homeserver.yaml
Edit the database entry
database:
name: psycopg2
args:
user: synapse_user
password: <pass>
database: synapse
host: localhost
cp_min: 5
cp_max: 10
Check if it works
systemctl restart matrix-synapse
systemctl status matrix-synapse
Setting up reverse proxy
NGINX Proxy Manager configuration without exposing admin API
Details:
Scheme: http
Forward Hostname / IP: 192.168.88.19
Port: 80
Custom Locations:
location: ~ ^(/_matrix|/_synapse/client)
Scheme: http
Forward Hostname / IP: 192.168.88.19
Port: 8008
Advanced:
listen 8448 ssl http2 default_server;
listen [::]:8448 ssl http2 default_server;
server_name matrix.flowerhouse.at;
If you want to expose admin api change location
location: ~ ^(/_matrix|/_synapse)
Check if federation configuration is correct: https://federationtester.matrix.org/
.well-known
NGINX Proxy Manager configuration without exposing admin API
Details:
Scheme: http
Forward Hostname / IP: 192.168.88.19
Port: 80
Custom Locations:
location: ~ ^(/_matrix|/_synapse/client)
Scheme: http
Forward Hostname / IP: 192.168.88.19
Port: 8008
Advanced:
listen 8448 ssl http2 default_server;
listen [::]:8448 ssl http2 default_server;
server_name matrix.flowerhouse.at;
Add User
register_new_matrix_user -c /etc/matrix-synapse/homeserver.yaml http://localhost:8008
Optional
Configure puppeting
Install required packages
apt install pip git pwgen
Activate synapse virtual enviroment
cd /opt/venvs/matrix-synapse
source ./bin/activate
Install packages
pip install git+https://github.com/devture/matrix-synapse-shared-secret-auth
deactivate
Generate shared secret
pwgen -s 128 1
Edit configuration and add configuration
nano /etc/matrix-synapse/homeserver.yaml
General information about puppeting
Administration
Administration-Tools:
- https://github.com/Awesome-Technologies/synapse-admin (WebUI)
- https://github.com/JOJ0/synadm (Console)
Or make API-Request with curl
Install Bridges
ffmpeg is needed to support media files
apt install ffmpeg
Installation
Create user for mautrix-whatsapp
adduser --system mautrix-whatsapp --home /opt/mautrix-whatsapp
Enter user folder
cd /opt/mautrix-whatsapp
Download binary from https://github.com/mautrix/whatsapp/releases
Rename binary
mv mautrix-whatsapp-amd64 mautrix-whatsapp
Create database
Open Postgres console
su - postgres
Create user for mautrix-whatsapp
createuser --pwprompt whatsapp_user
Create database for mautrix-whatsapp
createdb --encoding=UTF8 --locale=C --template=template0 --owner=whatsapp_user whatsapp
Exit Postgres console
exit
Configuration
Create and paste config file: mautrix-whatsapp-config.yaml
nano config.yaml
Modify permissions
chmod 755 mautrix-whatsapp
Generate the appservice registration file
./mautrix-whatsapp -g
Modify permissions
chmod 555 registration.yaml
Edit matrix-synapse configuration file
nano /etc/matrix-synapse/homeserver.yaml
To register WhatsApp add following lines
app_service_config_files:
- /opt/mautrix-whatsapp/registration.yaml
Restart matrix-synapse
systemctl restart matrix-synapse
Check if bridge works
./mautrix-whatsapp
systemd service
Create systemd service file and copy from service
nano /etc/systemd/system/mautrix-whatsapp.service
Apply changes
systemctl daemon-reload
Start and check status
systemctl start mautrix-whatsapp
systemctl status mautrix-whatsapp
Enable autostart
systemctl enable mautrix-whatsapp
Signal
Install Bridge
Create user for mautrix-signal
adduser --system mautrix-signal --home /opt/mautrix-signal
usermod -aG signald mautrix-signal
Enter user folder
cd /opt/mautrix-signal
Download binary from https://github.com/mautrix/signal/releases
Rename binary
mv mautrix-signal-amd64 mautrix-signal
Create database
Open Postgres console
su - postgres
Create user for mautrix-whatsapp
createuser --pwprompt signal_user
Create database for mautrix-whatsapp
createdb --encoding=UTF8 --locale=C --template=template0 --owner=signal_user signal
Exit Postgres console
exit
Configuration
Copy configuration file and edit...
cp example-config.yaml config.yaml
Modify permissions
chmod 755 mautrix-signal
Generate the appservice registration file
./mautrix-signal -g
Modify permissions
chmod 555 registration.yaml
Edit matrix-synapse configuration file
nano /etc/matrix-synapse/homeserver.yaml
To register mautrix-signal add following lines
app_service_config_files:
- /opt/mautrix-signal/registration.yaml
Restart matrix-synapse
systemctl restart matrix-synapse
Check if bridge works
./mautrix-signal
systemd service
Create systemd service file and copy from service
nano /etc/systemd/system/mautrix-signal.service
Apply changes
systemctl daemon-reload
Start and check status
systemctl start mautrix-signal
systemctl status mautrix-signal
Enable autostart
systemctl enable mautrix-signal
Telegram
Installation
Create user for bridge
adduser --system mautrix-telegram --home /opt/mautrix-telegram
Go to directory
cd /opt/mautrix-telegram
Create virtual environment
virtualenv -p /usr/bin/python3 .
Activate virtual environment
source ./bin/activate
Install signal bridge
pip install --upgrade mautrix-telegram[all]
Create database
Open Postgres console
su - postgres
Create user for mautrix-whatsapp
createuser --pwprompt telegram_user
Create database for mautrix-whatsapp
createdb --encoding=UTF8 --locale=C --template=template0 --owner=telegram_user telegram
Exit Postgres console
exit
Configuration
Copy configuration file and edit...
cp example-config.yaml config.yaml
Generate access file
python -m mautrix_telegram -g
Set permissions
chown -R mautrix-telegram:root ../mautrix-telegram/
Edit matrix-synapse configuration file
nano /etc/matrix-synapse/homeserver.yaml
To register WhatsApp add following lines
app_service_config_files:
- /opt/mautrix-telegram/registration.yaml
Restart matrix-synapse
systemctl restart matrix-synapse
Check if bridge works
python -m mautrix_telegram
systemd service
Create systemd service file and copy from service
nano /etc/systemd/system/mautrix-telegram.service
Apply changes
systemctl daemon-reload
Start and check status
systemctl start mautrix-telegram
systemctl status mautrix-telegram
Enable autostart
systemctl enable mautrix-telegram
IRC
Installation
Create user for bridge
adduser --system mautrix-irc --home /opt/mautrix-irc
Go to directory
cd /opt/mautrix-irc
Create virtual environment
virtualenv -p /usr/bin/python3 .
Activate virtual environment
source ./bin/activate
Install heisenbridge
pip install --upgrade heisenbridge[all]
Generate access file
python -m heisenbridge -c /opt/mautrix-irc/registration.yaml --generate
Set permissions
chown -R mautrix-irc:root ../mautrix-irc/
Edit matrix-synapse configuration file
nano /etc/matrix-synapse/homeserver.yaml
To register WhatsApp add following lines
app_service_config_files:
- /opt/mautrix-irc/registration.yaml
Restart matrix-synapse
systemctl restart matrix-synapse
Check if bridge works
python -m heisenbridge -c /opt/mautrix-irc/registration.yaml
If no .well-known file is configured, startup may take a few minutes
systemd service
Create systemd service file and copy from mautrix-irc.service
nano /etc/systemd/system/mautrix-irc.service
Apply changes
systemctl daemon-reload
Start and check status
systemctl start mautrix-irc
systemctl status mautrix-irc
Enable autostart
systemctl enable mautrix-irc
Configuration
This bridge is not configured with an config file but via the bot chat.
The first person chatting with the bot will automatically be set as the admin.
Set mediaurl
MEDIAURL https://matrix.flowerhouse.at
Install Element WebClient
Install webserver
apt install apache2
Go to directory
cd /var/www
Download binary from: https://github.com/vector-im/element-web/releases/
Untar and rename
tar -xvf element-v1.11.1.tar.gz
mv element-v1.11.1 element
rm element-v1.11.1.tar.gz
Configure host
nano /etc/apache2/sites-available/element.conf
Add to file
<VirtualHost *:80>
DocumentRoot /var/www/element
<Directory /var/www/element>
AllowOverride All
Order Allow,Deny
Allow from All
</Directory>
ErrorLog /var/log/apache2/element_error.log
</VirtualHost>
Activate new site
ln -s /etc/apache2/sites-available/element.conf /etc/apache2/sites-enabled/element.conf
To access via the IP-Address of the server
rm /etc/apache2/sites-enabled/000-default.conf
Configure apache to show pretty URL pathes
a2enmod rewrite
Restart webserver
service apache2 restart
Create config file
cd element
cp config.sample.json config.json
Edit config file
nano config.json