2021-01-01 12:47:53 +00:00
# Deploying Conduit
2020-08-12 19:17:53 +00:00
2021-01-01 12:47:53 +00:00
## Getting help
2020-08-12 19:17:53 +00:00
2021-04-19 09:57:17 +00:00
If you run into any problems while setting up Conduit, write an email to `timo@koesters.xyz` , ask us in `#conduit:matrix.org` or [open an issue on GitLab ](https://gitlab.com/famedly/conduit/-/issues/new ).
2020-08-12 19:17:53 +00:00
2021-01-01 12:47:53 +00:00
## Installing Conduit
2020-08-12 19:17:53 +00:00
2021-08-13 15:20:40 +00:00
You may simply download the binary that fits your machine. Run `uname -m` to see what you need. Now copy the right url:
2021-07-11 11:43:48 +00:00
2021-07-21 09:21:49 +00:00
| CPU Architecture | GNU (Ubuntu, Debian, ArchLinux, ...) | MUSL (Alpine, ... ) |
| -------------------- | ------------------------------------- | ----------------------- |
| x84_64 / amd64 | [Download][x84_64-gnu] | [Download][x84_64-musl] |
| armv7 (Raspberry Pi) | [Download][armv7-gnu] | - |
| armv8 / aarch64 | [Download][armv8-gnu] | - |
2021-07-11 11:43:48 +00:00
2021-08-13 15:20:40 +00:00
[x84_64-gnu]: https://gitlab.com/famedly/conduit/-/jobs/artifacts/master/raw/conduit-x86_64-unknown-linux-gnu?job=build:release:cargo:x86_64-unknown-linux-gnu
[x84_64-musl]: https://gitlab.com/famedly/conduit/-/jobs/artifacts/master/raw/conduit-x86_64-unknown-linux-musl?job=build:release:cargo:x86_64-unknown-linux-musl
[armv7-gnu]: https://gitlab.com/famedly/conduit/-/jobs/artifacts/master/raw/conduit-armv7-unknown-linux-gnueabihf?job=build:release:cargo:armv7-unknown-linux-gnueabihf
[armv8-gnu]: https://gitlab.com/famedly/conduit/-/jobs/artifacts/master/raw/conduit-aarch64-unknown-linux-gnu?job=build:release:cargo:aarch64-unknown-linux-gnu
2020-10-20 12:18:20 +00:00
2020-08-12 19:17:53 +00:00
```bash
2021-01-11 19:28:47 +00:00
$ sudo wget -O /usr/local/bin/matrix-conduit < url >
$ sudo chmod +x /usr/local/bin/matrix-conduit
2020-08-12 19:17:53 +00:00
```
2021-05-27 21:13:50 +00:00
Alternatively, you may compile the binary yourself using
2021-08-13 15:20:40 +00:00
2021-05-27 21:13:50 +00:00
```bash
$ cargo build --release
```
Note that this currently requires Rust 1.50.
2021-05-28 07:42:59 +00:00
If you want to cross compile Conduit to another architecture, read the [Cross-Compile Guide ](CROSS_COMPILE.md ).
2021-05-27 21:13:50 +00:00
2021-07-21 09:21:49 +00:00
2021-04-06 13:17:39 +00:00
## Adding a Conduit user
2021-04-06 12:26:47 +00:00
2021-04-11 10:51:43 +00:00
While Conduit can run as any user it is usually better to use dedicated users for different services.
2021-04-06 12:26:47 +00:00
This also allows you to make sure that the file permissions are correctly set up.
2021-04-06 13:17:39 +00:00
In Debian you can use this command to create a Conduit user:
2021-04-06 12:26:47 +00:00
2021-08-17 12:44:53 +00:00
```bash
2021-04-06 13:17:39 +00:00
sudo adduser --system conduit --no-create-home
```
2020-08-12 19:17:53 +00:00
2021-01-01 12:47:53 +00:00
## Setting up a systemd service
2020-08-12 19:17:53 +00:00
2021-01-01 12:47:53 +00:00
Now we'll set up a systemd service for Conduit, so it's easy to start/stop
Conduit and set it to autostart when your server reboots. Simply paste the
2020-10-20 12:18:20 +00:00
default systemd service you can find below into
2021-01-01 12:47:53 +00:00
`/etc/systemd/system/conduit.service` .
2020-08-12 19:17:53 +00:00
```systemd
[Unit]
2021-01-01 12:47:53 +00:00
Description=Conduit Matrix Server
2020-08-12 19:17:53 +00:00
After=network.target
[Service]
2021-01-01 12:47:53 +00:00
Environment="CONDUIT_CONFIG=/etc/matrix-conduit/conduit.toml"
2021-04-06 12:26:47 +00:00
User=conduit
Group=nogroup
2020-08-12 19:17:53 +00:00
Restart=always
2021-01-01 12:47:53 +00:00
ExecStart=/usr/local/bin/matrix-conduit
2020-08-12 19:17:53 +00:00
[Install]
WantedBy=multi-user.target
```
Finally, run
2021-04-15 21:08:13 +00:00
2020-08-12 19:17:53 +00:00
```bash
$ sudo systemctl daemon-reload
```
2021-01-01 12:47:53 +00:00
## Creating the Conduit configuration file
Now we need to create the Conduit's config file in `/etc/matrix-conduit/conduit.toml` . Paste this in **and take a moment to read it. You need to change at least the server name.**
2021-04-15 21:08:13 +00:00
2021-01-01 12:47:53 +00:00
```toml
[global]
# The server_name is the name of this server. It is used as a suffix for user
# and room ids. Examples: matrix.org, conduit.rs
# The Conduit server needs to be reachable at https://your.server.name/ on port
# 443 (client-server) and 8448 (federation) OR you can create /.well-known
# files to redirect requests. See
# https://matrix.org/docs/spec/client_server/latest#get-well-known-matrix-client
# and https://matrix.org/docs/spec/server_server/r0.1.4#get-well-known-matrix-server
# for more information
# YOU NEED TO EDIT THIS
#server_name = "your.server.name"
# This is the only directory where Conduit will save its data
database_path = "/var/lib/matrix-conduit/conduit_db"
2020-08-12 19:17:53 +00:00
2021-01-01 12:47:53 +00:00
# The port Conduit will be running on. You need to set up a reverse proxy in
# your web server (e.g. apache or nginx), so all requests to /_matrix on port
# 443 and 8448 will be forwarded to the Conduit instance running on this port
port = 6167
# Max size for uploads
max_request_size = 20_000_000 # in bytes
2021-08-31 16:25:35 +00:00
# Enables registration. If set to false, no users can register on this server.
allow_registration = true
2021-01-01 12:47:53 +00:00
# Disable encryption, so no new encrypted rooms can be created
# Note: existing rooms will continue to work
allow_encryption = true
allow_federation = true
2021-05-05 10:25:37 +00:00
trusted_servers = ["matrix.org"]
2021-05-24 15:59:06 +00:00
#max_concurrent_requests = 100 # How many requests Conduit sends to other servers at the same time
2021-01-01 12:47:53 +00:00
#workers = 4 # default: cpu core count * 2
address = "127.0.0.1" # This makes sure Conduit can only be reached using the reverse proxy
2021-07-14 07:07:08 +00:00
# The total amount of memory that the database will use.
#db_cache_capacity_mb = 200
2020-08-12 19:17:53 +00:00
```
2021-04-06 12:26:47 +00:00
## Setting the correct file permissions
2021-04-06 13:17:39 +00:00
As we are using a Conduit specific user we need to allow it to read the config.
To do that you can run this command on Debian:
2021-04-06 12:26:47 +00:00
2021-08-17 12:44:53 +00:00
```bash
2021-04-06 13:17:39 +00:00
sudo chown -R conduit:nogroup /etc/matrix-conduit
```
2021-04-06 12:26:47 +00:00
2021-04-06 13:17:39 +00:00
If you use the default database path you also need to run this:
2021-08-17 12:44:53 +00:00
```bash
2021-04-06 13:17:39 +00:00
sudo mkdir -p /var/lib/matrix-conduit/conduit_db
sudo chown -R conduit:nogroup /var/lib/matrix-conduit/conduit_db
```
2021-04-06 12:26:47 +00:00
2020-08-12 19:17:53 +00:00
2021-01-01 12:47:53 +00:00
## Setting up the Reverse Proxy
2020-08-12 19:17:53 +00:00
2021-01-01 12:47:53 +00:00
This depends on whether you use Apache, Nginx or another web server.
### Apache
Create `/etc/apache2/sites-enabled/050-conduit.conf` and copy-and-paste this:
2021-04-15 21:08:13 +00:00
2021-08-17 12:44:53 +00:00
```apache
2021-01-01 12:47:53 +00:00
Listen 8448
< VirtualHost *:443 * :8448 >
ServerName your.server.name # EDIT THIS
2020-08-12 19:17:53 +00:00
AllowEncodedSlashes NoDecode
2021-04-23 18:27:35 +00:00
ProxyPass /_matrix/ http://127.0.0.1:6167/_matrix/ nocanon
ProxyPassReverse /_matrix/ http://127.0.0.1:6167/_matrix/
2020-08-12 19:17:53 +00:00
Include /etc/letsencrypt/options-ssl-apache.conf
2021-01-01 12:47:53 +00:00
SSLCertificateFile /etc/letsencrypt/live/your.server.name/fullchain.pem # EDIT THIS
SSLCertificateKeyFile /etc/letsencrypt/live/your.server.name/privkey.pem # EDIT THIS
2020-08-12 19:17:53 +00:00
< / VirtualHost >
```
2021-01-01 12:47:53 +00:00
**You need to make some edits again.** When you are done, run
2021-04-15 21:08:13 +00:00
2020-08-12 19:17:53 +00:00
```bash
$ sudo systemctl reload apache2
```
2021-01-01 12:47:53 +00:00
### Nginx
If you use Nginx and not Apache, add the following server section inside the
http section of `/etc/nginx/nginx.conf`
2021-04-15 21:08:13 +00:00
2021-08-17 12:44:53 +00:00
```nginx
2021-01-01 12:47:53 +00:00
server {
2021-04-23 18:27:35 +00:00
listen 443 ssl http2;
listen [::]:443 ssl http2;
listen 8448 ssl http2;
listen [::]:8448 ssl http2;
2021-01-01 12:47:53 +00:00
server_name your.server.name; # EDIT THIS
2021-04-23 18:27:35 +00:00
merge_slashes off;
2021-01-01 12:47:53 +00:00
location /_matrix/ {
2021-04-23 18:27:35 +00:00
proxy_pass http://127.0.0.1:6167$request_uri;
proxy_set_header Host $http_host;
proxy_buffering off;
2021-01-01 12:47:53 +00:00
}
2021-04-23 18:27:35 +00:00
ssl_certificate /etc/letsencrypt/live/your.server.name/fullchain.pem; # EDIT THIS
ssl_certificate_key /etc/letsencrypt/live/your.server.name/privkey.pem; # EDIT THIS
ssl_trusted_certificate /etc/letsencrypt/live/your.server.name/chain.pem; # EDIT THIS
include /etc/letsencrypt/options-ssl-nginx.conf;
2021-01-01 12:47:53 +00:00
}
```
**You need to make some edits again.** When you are done, run
2021-04-15 21:08:13 +00:00
2021-01-01 12:47:53 +00:00
```bash
$ sudo systemctl reload nginx
```
2020-08-12 19:17:53 +00:00
## SSL Certificate
2021-01-01 12:47:53 +00:00
The easiest way to get an SSL certificate, if you don't have one already, is to install `certbot` and run this:
2021-04-15 21:08:13 +00:00
2020-08-12 19:17:53 +00:00
```bash
2021-01-01 12:47:53 +00:00
$ sudo certbot -d your.server.name
2020-08-12 19:17:53 +00:00
```
## You're done!
2020-10-20 12:18:20 +00:00
Now you can start Conduit with:
2021-04-15 21:08:13 +00:00
2020-08-12 19:17:53 +00:00
```bash
$ sudo systemctl start conduit
```
2020-10-20 12:18:20 +00:00
Set it to start automatically when your system boots with:
2021-04-15 21:08:13 +00:00
2020-08-12 19:17:53 +00:00
```bash
$ sudo systemctl enable conduit
```
2021-05-22 11:39:31 +00:00
2021-09-01 11:09:24 +00:00
## How do I know it works?
You can open < https: / / app . element . io > , enter your homeserver and try to register.
You can also use these commands as a quick health check.
```bash
$ curl https://your.server.name/_matrix/client/versions
$ curl https://your.server.name:8448/_matrix/client/versions
```
2021-05-22 11:39:31 +00:00
If you want to set up an appservice, take a look at the [Appservice Guide ](APPSERVICES.md ).