An alternative Telagram: how to run its own Mathx server using Docker Compose
Precondition:
Over the past few years, more and more people have been thinking about how safe it is to trust all their correspondence, contacts and digital communication with a large central platform. I don't want to just be a comfortable vigilante, but the feeling that your data really belong to you is that you control infrastructure yourself, decide where everything is stored, and don't depend on other rules, restrictions, or sudden changes in service policy.
This is where Matex comes in -- open federal communication protocol in real time. It's not just one service, it's not one website, it's a network of independent servers that can interact with each other. Unlike the usual meteorites where everything is tied to one company, Mathx does not have a single center that affects the whole system.
Each server called homeerver. You can log users, store messages, rooms, media files and phone readers. In this case, users of different homeerver can still communicate with themselves within one federal network. This is the main idea of Matrix: you can own your infrastructure, but you don't get global communication.
This approach is particularly good for someone who appreciates privacy, wants more control of their data and doesn't want to build critical communications on someone else's closed platform. Matrix doesn't promise magic or complete simplicity from the box, which gives a much more important thing -- freedom, transparency, and ability to rely on itself first.
This crowd -- for those who are generally familiar with Linux, DNS and Docker, but wants to go all the way from scratch: neat, consistent, and without skipping important details. As a result, you can raise your own Mathx server yourself and better understand how the federal communication is done in practice.
So what happens is
Once this is complete, you have the slope:
- own Matex-server on home equipment;
- working feudal;
- phone support for Ement X / Ement Call;
- can log users through Synapse Admin;
- an independent basis for personal, family or command communication.
What to prepare in advance:
1. Static Public IP Address
Check the provider's personal office, or the service available for the static public IP address. In many providers, it's connected separately.
2. Domain Name
Take care of the landlord's domain. No way. The domain itself is usually cheap, but with extended and incremental services, the total cost per year can be higher than the base price.
3. Old Internet connection server
Best use hardware connection to router overRJ-45(Sighs) Also check the server local IP address on your home network, for example:
192.168.0.172
4. SSH Access Server
For running Matrix, it works almost to be a computer, including an old laptop or a compact home server.
Recommended:
- better use
Ubuntu Serveror other distribution of Debian; - Windows for this script is not recommended;
- access to the server is desirable to configure via SSH.
Example connection:
ssh user@server_ip
5. Docker and Docker Compose
Docker and Docker Compose must be installed on the server. For this scenario, it's one of the most comfortable ways of expanding the Mathright stack.
Note: this haze assumes you already have a working
Nginx Proxy Manager(Sighs).
Step 1. Cloudflare DNS Configuration
1.1. NSI Domain Entries
Fill in the Domain Control Panel with the NSI servers of Cloudflare that have been issued for your zone.
Settings usually look like this:
Type:NSName:@Content: NSI servers issued by CloudflareTTL:Auto
1.2. CNAMEgt-write for Mathx
Create a CNAME entry:
Type:CNAMEName:matrixTarget:example.com- your domainProxy status:DNS onlyTTL:Auto
This entry is mandatory for main Matrix- Hoe:
matrix.example.com
That's where clients will connect to it.

1.3. DNS entry for the phone service
Create an Awrite:
Type:AName:matrixrtcIPv4:<ваш_публічний_IP>Proxy status:DNS onlyTTL:Auto
This recording will be required for the heart of the call.

This service is usually important for use modeDNS onlyas a proxy through the Cloudflare can prevent a valid Matrixcomponents and phone services.
Step 2. Nginx ProxManager Configuration
In this configuration you will need two proxy host:
matrix.example.commatrixrtc.example.com
2.1. Proxy Host formatrix.example.com
In TabDetailsspecify:
Domain Names:matrix.example.comScheme:httpForward Hostname / IP: local IP server address, for example192.168.0.172Forward Port:8008Access List:Publicly AccessibleCache Assets:ONBlock Common Exploits:ONWebsockets Support:ON

In TabCustom Locationsadd two locations.
Local 1:/.well-known/matrix/server
Options:
Scheme:httpForward Hostname / IP:127.0.0.1Forward Port:65535
In FieldCustom Nginx Configurationinsert:
default_type application/json;
add_header Access-Control-Allow-Origin *;
return 200 '{"m.server":"matrix.example.com:443"}';

Locale 2:/.well-known/matrix/client
Options:
Scheme:httpForward Hostname / IP:127.0.0.1Forward Port:65535
In FieldCustom Nginx Configurationinsert:
default_type application/json;
add_header Access-Control-Allow-Origin *;
return 200 '{
"m.homeserver": { "base_url": "https://matrix.example.com" },
"org.matrix.msc4143.rtc_foci": [
{
"type": "livekit",
"livekit_service_url": "https://matrixrtc.example.com/livekit/jwt"
}
]
}';

These addresses are for the following:
/.well-known/matrix/serverreports the feds at which your server is available;/.well-known/matrix/clienttells the Matrixclients which homeerver use and where the phone service is placed.
In TabSSLenable:
- certificate: woldcard or certificate on your domain, & eg
*.example.com Force SSL:ONHTTP/2 Support:ONHSTS Enabled:ONHSTS Subdomains:OFF

2.2. Proxy Host formatrixrtc.example.com
In TabDetailsspecify:
Domain Names:matrixrtc.example.comScheme:httpForward Hostname / IP: local IP server address, for example192.168.0.172Forward Port:7880Access List:Publicly AccessibleWebsockets Support:ONCache Assets:OFFBlock Common Exploits:OFF

FormatrixrtcadditionalCustom Locationsno need.
In TabSSLenable:
- certificate:
*.example.com Force SSL:ONHTTP/2 Support:ONHSTS Enabled:OFF

Step 3. Forward ports to router
The router needs to open and drop ports to the local IP address of the server.
The following rules are used in this example:
7881/TCP>192.168.0.172:7881LiveKit50100-50200/UDP>192.168.0.172:50100-50200LiveKit media traffic5349/TCP>192.168.0.172:5349-TURN over TLS3478/UDP>192.168.0.172:3478- TURN
It is important to understand that each router has its own interface, but the principle of setting up everything else: external port must be redirected to the internal address and port of your server.

Step 4. Starting Matrix
The first thing to do is to load the Docker Compose configuration fromGitHub repository:
git clone [email protected]:inne-dev/matrix-server.git
Then go to the project folder:
cd matrix-server
Use the environment variable template for fast startup:
cp .env.example .env
Then open a file.envand set:
MATRIX_DOMAIN- secrets with sufficient values:
POSTGRES_PASSWORDSYNAPSE_*_SECRETTURN_PASSWORDLIVEKIT_SECRET
Then generate a configuration as follows:
./scripts/render-configs.sh
Once you have created the configuration, raise the services:
docker compose up -d
To test the state of containers, use:
docker compose ps
docker compose logs --tail=100 synapse
Step 5. Create first user
When the stack is started, create the first user using the built-in Synapse utility from the container:
docker exec -it synapse register_new_matrix_user \
-c /data/homeserver.yaml \
http://localhost:8008
Then, in interactive mode, the wizard asks:
- username;
- password;
- i don't know if to give this user root privileges.
Step 6. Clipper
You can use:
- on smart--Element X
- on computer --Element Desktop
Specify your own homeerver when you login, for example:
https://matrix.example.com
After that, you can enter your account, connect to the server and start using the Matrixinfrastructure of your own.
For whom this guide is
This material will be useful if you search for:
- secure furniture for personal use;
- open mager for command or community;
- how to raise your own furniture on the home server;
- a solution that is less dependent on one company;
- more private and controlled way of communicating.
Summary
You end up getting your own independent communication diagram. This server can be used for personal communication, family, small commands, closed communities or technical objects where important control over infrastructure, autonomy and predictability.
The main advantage of Matrix is that this is not a centralized furniture, completely bound to one operator. This is an open federal network where you can expand your own homeerver, manage users, connect customers, and, if necessary, expand the system with additional services.
If you want your own furniture on your home server, or just a more self-personally way to keep the connection, the Matrix looks like one of the most powerful options. Yes, this approach is the front of the login threshold: you have to deal with DNS, certificates, output proxy, forward ports and basic container configuration. But instead, you get flexibility, independence and control levels that don't normally give you regular consumer medals.
Frequently asked questions
Is it hard to pick up your own MathxServer?
The Matrix base is not too complicated if you are already running from Linux, Docker, DNS and repeat proxy. The main complexity is not usually about Synapse, but in the correct setting of the domain, LST certificates, Federation and phone services.
Can I use Matrix for a family or a small team?
Yeah. Matrix works well for personal communication, and for small teams, family tips, closed communities or technical objects where important autonomy, control and predictability.
Do you have to raise the server at home?
No. You can expand Matex as on the home server, as well as the VPS or another rental infrastructure. The home server is only one of the possible options if you need to fully control your system.
Will Matrix replace the normal popular furniture?
For many scenarios, yes, especially if you care about independence, privacy and control over infrastructure. But it's worth considering that Matex needs a little bit more technical training and doesn't always produce the same level of simplicity that offers mass consumer services.
Leave a comment