Compare commits
No commits in common. "1837e81c3d2352862385b0180eb5617991a467a1" and "dc62f080c881bf6fd5f18693c1dd76913fac2ca9" have entirely different histories.
1837e81c3d
...
dc62f080c8
3 changed files with 25 additions and 45 deletions
32
Justfile
32
Justfile
|
@ -7,42 +7,19 @@
|
|||
|
||||
# Stop the instance [aliases: s]
|
||||
@stop:
|
||||
sudo docker-compose stop
|
||||
sudo docker-compose rm -f -s
|
||||
|
||||
# Restart the instance
|
||||
@restart:
|
||||
sudo docker-compose restart
|
||||
|
||||
# Create Backup file [aliases: b]
|
||||
@backup backup_name:
|
||||
@backup backup_name: stop && run
|
||||
#!/usr/bin/env bash
|
||||
DATABASE_BACKUP_FILE="synapse-postgres-backup-$(date +%d-%m-%Y"_"%H%M%S).sql.gz"
|
||||
sudo docker-compose exec postgresql bash -c "export PGPASSWORD=somepassword && pg_dump -U synapse synapse" | \
|
||||
gzip -9 > $DATABASE_BACKUP_FILE
|
||||
FILES="data postgresdata Justfile docker-compose.yml README.md $DATABASE_BACKUP_FILE"
|
||||
FILES="data postgresdata Justfile docker-compose.yml README.md"
|
||||
7z a -t7z -m0=lzma2 -mx=9 -mfb=64 -md=32m -ms=on -mhe=on -p {{backup_name}}.7z $FILES
|
||||
rm -fr $DATABASE_BACKUP_FILE
|
||||
echo "Backup done..."
|
||||
|
||||
# Restore Backup file
|
||||
@restore backup_name: stop && run
|
||||
#!/usr/bin/env bash
|
||||
7z x {{backup_name}}.7z -aoa
|
||||
DATABASE_BACKUP_FILE=$(ls synapse-postgres-backup-*.sql.gz)
|
||||
DATABASE_FILE=$(echo $DATABASE_BACKUP_FILE | sed 's/.gz//')
|
||||
# Run the database to write the sql file to the container
|
||||
sudo docker-compose up -d postgresql
|
||||
|
||||
gunzip -k $DATABASE_BACKUP_FILE && \
|
||||
sudo docker cp $DATABASE_FILE postgresql_synapse:/pg-backup.sql && \
|
||||
sudo docker-compose exec postgresql bash -c "export PGPASSWORD=somepassword && dropdb -U synapse synapse --force && createdb -U synapse synapse && psql -U synapse synapse < pg-backup.sql"
|
||||
rm -fr $DATABASE_FILE
|
||||
rm -fr $DATABASE_BACKUP_FILE
|
||||
|
||||
# Stop the database container (it will be started by the run command)
|
||||
sudo docker-compose stop postgresql
|
||||
echo "Restore done..."
|
||||
|
||||
|
||||
[private]
|
||||
alias r := run
|
||||
|
@ -50,5 +27,4 @@ alias r := run
|
|||
alias s := stop
|
||||
[private]
|
||||
alias b := backup
|
||||
[private]
|
||||
alias re := restore
|
||||
|
||||
|
|
37
README.md
37
README.md
|
@ -4,7 +4,7 @@ This is my personal matrix homeserver. You can clone this repository and run the
|
|||
|
||||
## Overview
|
||||
In this repository I use `4rs.nl` (my domain) as an example. You should replace this with your own domain.
|
||||
After reading this README you should have a `/.well-known/matrix/server` and `/.well-known/matrix/client` file on your domain (4rs.nl). The client will use `matrix.4rs.nl` as the homeserver and the displayed server name will be `4rs.nl`.
|
||||
After reading this README you should have a `/.well-known/matrix/server` and `/.well-known/matrix/client` file on your domain (4rs.nl) and your matrix subdomain (matrix.4rs.nl). The client will use `matrix.4rs.nl` as the homeserver and the displayed homeserver will be `4rs.nl`.
|
||||
|
||||
## Requirements
|
||||
- docker
|
||||
|
@ -12,14 +12,14 @@ After reading this README you should have a `/.well-known/matrix/server` and `/.
|
|||
- nginx
|
||||
|
||||
## Domain requirements
|
||||
- Have a `/.well-known/matrix/server` file on your domain (server name) that points to your homeserver. This is required for federation to work.
|
||||
- Have a `/.well-known/matrix/server` file on your domain that points to your homeserver. This is required for federation to work.
|
||||
The content of the file should be:
|
||||
```
|
||||
{
|
||||
"m.server": "matrix.4rs.nl:443"
|
||||
}
|
||||
```
|
||||
- Have a `/.well-known/matrix/client` file on your domain (server name) that points to your homeserver. This is required for the client to work.
|
||||
- Have a `/.well-known/matrix/client` file on your domain that points to your homeserver. This is required for the client to work.
|
||||
The content of the file should be:
|
||||
```
|
||||
{
|
||||
|
@ -29,8 +29,7 @@ The content of the file should be:
|
|||
}
|
||||
```
|
||||
|
||||
For me, I created the files in my static blog and then deployed it in GitHub pages. See the files [here](https://git.4rs.nl/awiteb/blog/src/branch/master/static/.well-known/matrix) in my blog repository.
|
||||
You can use any other method to deploy the files and make them accessible on your domain, as long as they are accessible at `/.well-known/matrix/server` and `/.well-known/matrix/client`.
|
||||
For me, I created the files in my static blog and then deployed it in GitHub pages. See the [justfile that I use to deploy the files to the domain](https://git.4rs.nl/awiteb/blog/src/branch/master/Justfile#L15-L17). You can use any other method to deploy the files and make them accessible on your domain, as long as they are accessible at `/.well-known/matrix/server` and `/.well-known/matrix/client`.
|
||||
|
||||
|
||||
## Nginx configuration of the matrix subdomain
|
||||
|
@ -88,7 +87,17 @@ server {
|
|||
client_body_timeout 5s;
|
||||
client_header_timeout 5s;
|
||||
|
||||
location / {
|
||||
location /.well-known/matrix/server {
|
||||
return 200 '{"m.server": "matrix.4rs.nl:443"}';
|
||||
default_type application/json;
|
||||
add_header Access-Control-Allow-Origin *;
|
||||
}
|
||||
location /.well-known/matrix/client {
|
||||
return 200 '{"m.homeserver": {"base_url": "https://matrix.4rs.nl}}';
|
||||
default_type application/json;
|
||||
add_header Access-Control-Allow-Origin *;
|
||||
}
|
||||
location / {
|
||||
proxy_pass http://localhost:8008;
|
||||
proxy_set_header X-Forwarded-For $remote_addr;
|
||||
client_max_body_size 200M;
|
||||
|
@ -107,13 +116,12 @@ After you have cloned the repository, replace all `4rs.nl` with your domain also
|
|||
|
||||
There is tow things only you need to change it, the first one is the secrets in `./data/homeserver.yaml` and the second one is the signing key in `./data/4rs.nl.signing.key`.
|
||||
|
||||
### homeserver.yaml
|
||||
### Homeserver.yaml
|
||||
After replacing all `4rs.nl` with your domain, you need to generate a secret for each secret in the `homeserver.yaml` file. You can generate a secret with `openssl rand -base64 32`. Replace the secret with the generated secret.
|
||||
|
||||
### Signing key
|
||||
|
||||
> [!NOTE]
|
||||
>
|
||||
> **Note**
|
||||
> You need `signedjson` dependency to generate a signing key. You can install it with `pip3 install signedjson`.
|
||||
|
||||
Change the content of the `4rs.nl.signing.key` file with a generated key. You can generate a key with `generate_signing_key` script in root of the repository. Run `python3 generate_signing_key` and replace the content of the `4rs.nl.signing.key` file with the generated key.
|
||||
|
@ -124,15 +132,12 @@ After all above steps, you can run the homeserver with `docker-compose up -d`. Y
|
|||
|
||||
Now you need to create an admin user with `docker exec -it synapse register_new_matrix_user http://localhost:8008 -c /data/homeserver.yaml` and follow the instructions. You should now have an admin user on the homeserver and you can login with it on the client using the homeserver `matrix.4rs.nl`. Enjoy your homeserver!
|
||||
|
||||
> [!NOTE]
|
||||
>
|
||||
> You need [`just`](https://just.systems/) to backup and restore your homeserver. You can install it with `cargo install just`.
|
||||
|
||||
## Backup
|
||||
You can backup the homeserver with `just backup <backup-name>`. And it's will stored as encrypted AES256 7z file.
|
||||
|
||||
## Restore
|
||||
To restore the homeserver, you can use `just restore <backup-name>`. Make sure to run it in the root of the repository.
|
||||
> **Note**
|
||||
> You need [`just`](https://just.systems/) to backup the homeserver. You can install it with `cargo install just`.
|
||||
|
||||
You can backup the homeserver with `just backup <backup-name>`. And it's will stored as encrypted AES256 7z file.
|
||||
|
||||
## Any questions?
|
||||
If you have any questions, you can contact with me at `@awiteb:4rs.nl` and I will try to help you. Have fun with your homeserver!
|
||||
|
|
|
@ -14,7 +14,6 @@ services:
|
|||
- "8008:8008/tcp"
|
||||
- "8448:8448/tcp"
|
||||
postgresql:
|
||||
container_name: postgresql_synapse
|
||||
image: postgres:latest
|
||||
restart: always
|
||||
environment:
|
||||
|
|
Loading…
Reference in a new issue