2024-03-21 23:16:20 -04:00
# Generic deployment documentation
2024-12-15 22:46:56 -05:00
> ### Getting help
2024-03-21 23:16:20 -04:00
>
2025-04-20 23:50:48 +01:00
> If you run into any problems while setting up Continuwuity, ask us in
> `#continuwuity:continuwuity.org` or [open an issue on
> Forgejo](https://forgejo.ellis.link/continuwuation/continuwuity/issues/new).
2024-03-21 23:16:20 -04:00
2025-04-20 23:50:48 +01:00
## Installing Continuwuity
2024-03-21 23:16:20 -04:00
2024-12-15 22:46:56 -05:00
### Static prebuilt binary
You may simply download the binary that fits your machine architecture (x86_64
or aarch64). Run `uname -m` to see what you need.
2024-03-21 23:16:20 -04:00
2024-08-24 05:13:43 +02:00
Prebuilt fully static musl binaries can be downloaded from the latest tagged
2025-04-20 23:50:48 +01:00
release [here ](https://forgejo.ellis.link/continuwuation/continuwuity/releases/latest ) or
2024-12-15 22:46:56 -05:00
`main` CI branch workflow artifact output. These also include Debian/Ubuntu
packages.
These can be curl'd directly from. `ci-bins` are CI workflow binaries by commit
hash/revision, and `releases` are tagged releases. Sort by descending last
modified for the latest.
2024-09-17 18:55:08 -04:00
2024-08-24 05:13:43 +02:00
These binaries have jemalloc and io_uring statically linked and included with
2024-09-17 18:55:08 -04:00
them, so no additional dynamic dependencies need to be installed.
2024-03-21 23:16:20 -04:00
2024-12-15 22:46:56 -05:00
For the **best** performance; if using an `x86_64` CPU made in the last ~15 years,
we recommend using the `-haswell-` optimised binaries. This sets
`-march=haswell` which is the most compatible and highest performance with
optimised binaries. The database backend, RocksDB, most benefits from this as it
will then use hardware accelerated CRC32 hashing/checksumming which is critical
for performance.
### Compiling
2024-08-24 05:13:43 +02:00
Alternatively, you may compile the binary yourself. We recommend using
2025-04-20 23:50:48 +01:00
Nix (or [Lix ](https://lix.systems )) to build Continuwuity as this has the most
2024-12-15 22:46:56 -05:00
guaranteed reproducibiltiy and easiest to get a build environment and output
going. This also allows easy cross-compilation.
2024-09-17 18:55:08 -04:00
2024-10-24 23:03:36 -04:00
You can run the `nix build -L .#static-x86_64-linux-musl-all-features` or
`nix build -L .#static-aarch64-linux-musl-all-features` commands based
2024-09-17 18:55:08 -04:00
on architecture to cross-compile the necessary static binary located at
2024-12-15 22:46:56 -05:00
`result/bin/conduwuit` . This is reproducible with the static binaries produced
in our CI.
If wanting to build using standard Rust toolchains, make sure you install:
- `liburing-dev` on the compiling machine, and `liburing` on the target host
- LLVM and libclang for RocksDB
2024-03-21 23:16:20 -04:00
2025-04-20 23:50:48 +01:00
You can build Continuwuity using `cargo build --release --all-features`
2024-03-21 23:16:20 -04:00
2025-04-20 23:50:48 +01:00
## Adding a Continuwuity user
2024-03-21 23:16:20 -04:00
2025-04-20 23:50:48 +01:00
While Continuwuity can run as any user it is better to use dedicated users for
2024-08-24 05:13:43 +02:00
different services. This also allows you to make sure that the file permissions
are correctly set up.
2024-03-21 23:16:20 -04:00
2025-04-20 23:50:48 +01:00
In Debian, you can use this command to create a Continuwuity user:
2024-03-21 23:16:20 -04:00
```bash
2025-04-20 23:50:48 +01:00
sudo adduser --system continuwuity --group --disabled-login --no-create-home
2024-03-21 23:16:20 -04:00
```
2024-11-17 11:12:57 +08:00
For distros without `adduser` (or where it's a symlink to `useradd` ):
2024-05-08 21:26:05 -04:00
2024-08-30 18:54:41 -04:00
```bash
2025-04-20 23:50:48 +01:00
sudo useradd -r --shell /usr/bin/nologin --no-create-home continuwuity
2024-08-30 18:54:41 -04:00
```
2024-05-08 21:26:05 -04:00
2024-03-21 23:16:20 -04:00
## Forwarding ports in the firewall or the router
2024-11-15 12:58:02 -05:00
Matrix's default federation port is port 8448, and clients must be using port 443.
If you would like to use only port 443, or a different port, you will need to setup
2025-04-20 23:50:48 +01:00
delegation. Continuwuity has config options for doing delegation, or you can configure
2024-11-15 12:58:02 -05:00
your reverse proxy to manually serve the necessary JSON files to do delegation
(see the `[global.well_known]` config section).
2024-03-21 23:16:20 -04:00
2025-04-20 23:50:48 +01:00
If Continuwuity runs behind a router or in a container and has a different public
2024-08-24 05:13:43 +02:00
IP address than the host system these public ports need to be forwarded directly
or indirectly to the port mentioned in the config.
2024-03-21 23:16:20 -04:00
2024-11-15 12:58:02 -05:00
Note for NAT users; if you have trouble connecting to your server from the inside
of your network, you need to research your router and see if it supports "NAT
hairpinning" or "NAT loopback".
If your router does not support this feature, you need to research doing local
DNS overrides and force your Matrix DNS records to use your local IP internally.
This can be done at the host level using `/etc/hosts` . If you need this to be
on the network level, consider something like NextDNS or Pi-Hole.
2024-03-21 23:16:20 -04:00
## Setting up a systemd service
2025-04-20 23:50:48 +01:00
Two example systemd units for Continuwuity can be found
2024-12-11 18:22:51 -05:00
[on the configuration page ](../configuration/examples.md#debian-systemd-unit-file ).
2025-04-20 23:50:48 +01:00
You may need to change the `ExecStart=` path to where you placed the Continuwuity
2024-12-11 18:22:51 -05:00
binary if it is not `/usr/bin/conduwuit` .
2024-03-21 23:16:20 -04:00
2024-12-11 18:22:51 -05:00
On systems where rsyslog is used alongside journald (i.e. Red Hat-based distros
and OpenSUSE), put `$EscapeControlCharactersOnReceive off` inside
`/etc/rsyslog.conf` to allow color in logs.
If you are using a different `database_path` other than the systemd unit
configured default `/var/lib/conduwuit` , you need to add your path to the
systemd unit's `ReadWritePaths=` . This can be done by either directly editing
`conduwuit.service` and reloading systemd, or running `systemctl edit conduwuit.service`
and entering the following:
```
[Service]
ReadWritePaths=/path/to/custom/database/path
```
2024-10-19 11:12:41 +08:00
2025-04-20 23:50:48 +01:00
## Creating the Continuwuity configuration file
2024-03-21 23:16:20 -04:00
2025-04-20 23:50:48 +01:00
Now we need to create the Continuwuity's config file in
2025-05-10 20:37:08 +01:00
`/etc/continuwuity/continuwuity.toml` . The example config can be found at
2024-08-30 18:54:41 -04:00
[conduwuit-example.toml ](../configuration/examples.md ).
2024-12-11 18:22:51 -05:00
**Please take a moment to read the config. You need to change at least the
server name.**
2024-03-21 23:16:20 -04:00
2024-06-26 19:25:44 -04:00
RocksDB is the only supported database backend.
2024-03-21 23:16:20 -04:00
## Setting the correct file permissions
2025-04-20 23:50:48 +01:00
If you are using a dedicated user for Continuwuity, you will need to allow it to
2024-08-24 05:13:43 +02:00
read the config. To do that you can run this:
2024-03-21 23:16:20 -04:00
```bash
2024-10-23 19:59:56 -04:00
sudo chown -R root:root /etc/conduwuit
sudo chmod -R 755 /etc/conduwuit
2024-03-21 23:16:20 -04:00
```
If you use the default database path you also need to run this:
2024-08-30 18:54:41 -04:00
```bash
2024-10-23 19:59:56 -04:00
sudo mkdir -p /var/lib/conduwuit/
2025-04-20 23:50:48 +01:00
sudo chown -R continuwuity:continuwuity /var/lib/conduwuit/
2024-08-30 18:54:41 -04:00
sudo chmod 700 /var/lib/conduwuit/
2024-03-21 23:16:20 -04:00
```
## Setting up the Reverse Proxy
2025-03-10 21:27:53 +00:00
We recommend Caddy as a reverse proxy, as it is trivial to use, handling TLS certificates, reverse proxy headers, etc transparently with proper defaults.
For other software, please refer to their respective documentation or online guides.
2024-09-17 18:55:08 -04:00
2025-03-10 21:27:53 +00:00
### Caddy
2024-03-21 23:16:20 -04:00
2025-03-10 21:27:53 +00:00
After installing Caddy via your preferred method, create `/etc/caddy/conf.d/conduwuit_caddyfile`
and enter this (substitute for your server name).
2024-10-27 12:19:45 -04:00
2025-03-10 21:27:53 +00:00
```caddyfile
your.server.name, your.server.name:8448 {
# TCP reverse_proxy
reverse_proxy 127.0.0.1:6167
# UNIX socket
#reverse_proxy unix//run/conduwuit/conduwuit.sock
}
```
2024-10-27 12:19:45 -04:00
2025-03-10 21:27:53 +00:00
That's it! Just start and enable the service and you're set.
2024-09-17 18:55:08 -04:00
2025-03-10 21:27:53 +00:00
```bash
sudo systemctl enable --now caddy
```
### Other Reverse Proxies
As we would prefer our users to use Caddy, we will not provide configuration files for other proxys.
2024-09-17 18:55:08 -04:00
You will need to reverse proxy everything under following routes:
- `/_matrix/` - core Matrix C-S and S-S APIs
2025-07-12 03:50:26 -05:00
- `/_conduwuit/` and/or `/_continuwuity/` - ad-hoc Continuwuity routes such as `/local_user_count` and
2024-09-17 18:55:08 -04:00
`/server_version`
You can optionally reverse proxy the following individual routes:
- `/.well-known/matrix/client` and `/.well-known/matrix/server` if using
2025-04-20 23:50:48 +01:00
Continuwuity to perform delegation (see the `[global.well_known]` config section)
- `/.well-known/matrix/support` if using Continuwuity to send the homeserver admin
2024-09-17 18:55:08 -04:00
contact and support page (formerly known as MSC1929)
- `/` if you would like to see `hewwo from conduwuit woof!` at the root
2024-06-02 18:00:38 -04:00
2024-11-10 20:20:27 -05:00
See the following spec pages for more details on these files:
- [`/.well-known/matrix/server` ](https://spec.matrix.org/latest/client-server-api/#getwell-knownmatrixserver )
- [`/.well-known/matrix/client` ](https://spec.matrix.org/latest/client-server-api/#getwell-knownmatrixclient )
- [`/.well-known/matrix/support` ](https://spec.matrix.org/latest/client-server-api/#getwell-knownmatrixsupport )
Examples of delegation:
- < https: // puppygock . gay /. well-known / matrix / server >
- < https: // puppygock . gay /. well-known / matrix / client >
2025-03-10 21:27:53 +00:00
For Apache and Nginx there are many examples available online.
2024-03-21 23:16:20 -04:00
2025-03-10 21:27:53 +00:00
Lighttpd is not supported as it seems to mess with the `X-Matrix` Authorization
header, making federation non-functional. If a workaround is found, feel free to share to get it added to the documentation here.
2024-03-21 23:16:20 -04:00
2025-03-10 21:27:53 +00:00
If using Apache, you need to use `nocanon` in your `ProxyPass` directive to prevent httpd from messing with the `X-Matrix` header (note that Apache isn't very good as a general reverse proxy and we discourage the usage of it if you can).
2024-03-21 23:16:20 -04:00
2025-04-20 23:50:48 +01:00
If using Nginx, you need to give Continuwuity the request URI using `$request_uri` , or like so:
2025-03-10 21:27:53 +00:00
- `proxy_pass http://127.0.0.1:6167$request_uri;`
- `proxy_pass http://127.0.0.1:6167;`
2024-03-21 23:16:20 -04:00
2025-03-10 21:27:53 +00:00
Nginx users need to increase `client_max_body_size` (default is 1M) to match
`max_request_size` defined in conduwuit.toml.
2024-03-21 23:16:20 -04:00
2024-07-03 03:49:33 -04:00
## You're done
2024-03-21 23:16:20 -04:00
2025-04-20 23:50:48 +01:00
Now you can start Continuwuity with:
2024-03-21 23:16:20 -04:00
2024-08-30 18:54:41 -04:00
```bash
sudo systemctl start conduwuit
```
2024-03-21 23:16:20 -04:00
Set it to start automatically when your system boots with:
2024-08-30 18:54:41 -04:00
```bash
sudo systemctl enable conduwuit
```
2024-03-21 23:16:20 -04:00
## How do I know it works?
2024-08-24 05:13:43 +02:00
You can open [a Matrix client ](https://matrix.org/ecosystem/clients ), enter your
homeserver and try to register.
2024-03-21 23:16:20 -04:00
2024-08-24 05:13:43 +02:00
You can also use these commands as a quick health check (replace
`your.server.name` ).
2024-03-21 23:16:20 -04:00
2024-08-30 18:54:41 -04:00
```bash
curl https://your.server.name/_conduwuit/server_version
2024-03-21 23:16:20 -04:00
2024-08-30 18:54:41 -04:00
# If using port 8448
curl https://your.server.name:8448/_conduwuit/server_version
2024-09-17 18:55:08 -04:00
# If federation is enabled
curl https://your.server.name:8448/_matrix/federation/v1/version
2024-08-30 18:54:41 -04:00
```
2024-03-21 23:16:20 -04:00
2024-08-24 05:13:43 +02:00
- To check if your server can talk with other homeservers, you can use the
[Matrix Federation Tester ](https://federationtester.matrix.org/ ). If you can
register but cannot join federated rooms check your config again and also check
if the port 8448 is open and forwarded correctly.
2024-03-21 23:16:20 -04:00
# What's next?
## Audio/Video calls
For Audio/Video call functionality see the [TURN Guide ](../turn.md ).
## Appservices
2024-08-24 05:13:43 +02:00
If you want to set up an appservice, take a look at the [Appservice
Guide](../appservices.md).