Matrix Element Collaboration Server
(posted 2023.11.22, last updated 2024.04.14)

I had to move away from an external slack instance that was used for work collaboration. Because of that I was looking for alternatives and decided to try out to host a Element instance myself.

Setup

enable_registration: true registration_requires_token: true suppress_key_server_warning: true

serve /.well-known/matrix/server to allow federation without seperate port.

serve_server_wellknown: true

Prevent other servers from fetching public rooms

allow_public_rooms_without_auth: false allow_public_rooms_over_federation: false

Federation server whitelist, defaults to allow all

federation_domain_whitelist:

Prevent joining of "complex" (resource intensive) rooms

limit_remote_rooms: enabled: true admins_can_join: true



- nginx server: `nano /etc/nginx/conf.d/matrix-element.conf`
server {
    listen 443 ssl;
    listen [::]:443 ssl;
    server_name matrix.domain.tld;

    ssl_certificate /etc/nginx/ssl/domain.tld.pem;
    ssl_certificate_key /etc/nginx/ssl/domain.tld.key;
    ssl_trusted_certificate /etc/nginx/ssl/domain.tld.pem;

    proxy_connect_timeout 300s;
    proxy_send_timeout 300s;
    proxy_read_timeout 300s;
    proxy_set_header X-Forwarded-For $remote_addr;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header Host $host;
    client_max_body_size 50M;

    location ~ ^(/_matrix|/_synapse/client|/_synapse/admin|/.well-known/matrix/) {
        proxy_pass http://127.0.0.1:8702;
    }

    location / {
        proxy_pass http://127.0.0.1:8703/;
    }
}

server {
    listen 443 ssl;
    listen [::]:443 ssl;
    server_name element.domain.tld;

    ssl_certificate /etc/nginx/ssl/domain.tld.pem;
    ssl_certificate_key /etc/nginx/ssl/domain.tld.key;
    ssl_trusted_certificate /etc/nginx/ssl/domain.tld.pem;

    proxy_connect_timeout 300s;
    proxy_send_timeout 300s;
    proxy_read_timeout 300s;

    location / {
        proxy_pass http://127.0.0.1:8701;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header Host $host;
        client_max_body_size 50M;
    }
}
~~~

References