Matrix Synapse Docker with Nginx Proxy Manager (NPM)

Version: 25.4.17

In the following tutorial we want to install Matrix Synapse including SSL certificates from Letsencrypt with the Nginx Proxy Manager on a VPS on the Internet (in our case at Hetzner.com).

A big thank you goes to Patrick from https://www.cleveradmin.de/ with whom I worked out a great solution!

🛠 Requirements:
– A domain is available with access to the DNS entries
– VPS is set up with root access (Ubuntu)

A small server from e.g. Hetzner.com is sufficient here:

⚠️ Firewall: Please configure the firewall at Hetzner and only allow the following ports:

TCP: 22, 80, 81, 443 (Matrix Synapse, NPM)
TCP: 7881-7882 and UDP 50100 – 50200 are the preparation for Element Call

⚠️ DNS access must also be available for an existing domain:

We start and log in to the server:

First we make sure that the server is up to date with the following command:

We then restart the server and log in again:

We create the folders for our two projects (Synapse and Nginx Proxy Manager -NPM-)

Now we first install Docker by creating a file called “install.sh” in the /home/ directory:

The file contains the following content (thanks to Patrick Asmus: https://git.techniverse.net/scriptos/public-linux-docker-installer)

We then execute the file:

After completing the script, Docker and Docker-Compose are installed.

⚠️ Important: We are now creating a special network in which the individual containers will later operate together:

We start with Matrix Synapse and go to the synapse folder and execute the following command:

⚠️ “subdomain.deinedomain.de” is of course changed beforehand with your own domain. e.g.: matrix.deinedomain.de

The script has now created the so-called homeserver.yaml file in the /synapse/data/ folder.

We open this with :

The file should look like this:

⚠️ It is important to change the database settings as follows:

This deactivates the SQL3 database and activates Postgres.

We save the file (CTRL+O) and close the editor again (CTRL+X) and now create the “docker-compose.yml” file in the Synapse folder:

You can use the following Compose file and modify it with your data (change the password for Postgres):

Now let’s go back to the project directory and start the container:

We can query the result with “docker ps” in the command line. We should see that the containers (Synapse and the database) are running as “Healthy”:

We create the first user (Admin) with the following command:

⚠️ Important: change back to the /home/synapse/ directory!

Explanation:

  • -u: desired user name
  • -p: password
  • -a: makes the user an admin (optional)
  • -k: shared secret from homeserver.yaml
  • http://localhost:8008: Synapse Admin-API-Endpunkt (Pay attention to correct address, possibly http://synapse:8008 within Compose)

✅ Done: Part 1 is complete. Matrix Synapse is installed. Congratulations! You can verify this by visiting the URL:

http://server-ip:8008

Next step: NPM – Install Nginx Proxy Manager as Docker (SSL certificate / HTTPS)

We add the following code to the file:

Now we’ll ensure that the database is always started alongside NPM at system startup. This doesn’t always work in docker-compose.yml, and you can’t log in to NPM on the interface.

🛠 The solution is a: “systemd-Service”

Create Service File (z. B. /etc/systemd/system/npm-stack.service):

⚠️ Adjust the WorkingDirectory path to the folder containing docker-compose.yml (/home/npm)

Activate and start:

✅ Result:

Now the entire NPM stack—including mariadb-aria—starts automatically when the system boots, without having to manually run docker compose up. We start the NPM container by navigating to the /home/npm/ directory and executing the following command:

Now we open the NPM admin interface using: http://IP-ADDRESS:81 and get the following screen:

We log in with: – admin@example.com – changeme And we can now assign our own user credentials. It’s important now that we create various subdomains: – npm.domain.de – matrix.domain.de The subdomains point to the VPS on which everything is installed in Hetzner’s DNS settings. Once we’ve done that, we’ll continue with NPM:

In NPM we now click on “Hosts” -> “Proxy Hosts” -> “Add Proxy Host” and add the following:

⚠️ Important: The containers’ internal Docker IPs are used for forwarding. This prevents future errors. We set up the special Docker network at the very beginning of the tutorial for this purpose. All containers are on the same network. Continue: Then click on the SSL tab:

Now click Save and you’ve set up a reverse proxy. Your Matrix server is now accessible via https:// at “matrix.domainname.de.” Do the same with NPM to ensure it’s also secured via SSL:

And again request the SSL certificate under SSL.

The SSL certificates can now be viewed in NPM under “SSL Certificates”:

✅ Done! Matrix Synapse with NPM (both in Docker containers) has been installed on a VPS on the internet.


If you want to know how to install Element Call, check out Patrick’s tutorial:
https://www.cleveradmin.de/blog/2025/04/matrixrtc-element-call-backend-einrichten/


bc1q8dxp9mlt3mkvaklu2vn8j6jteqyv53kschc90v

Lightning: tom@blitz.cmdsrv.de