From 72cd04329bf6ac01186383c07c0f28a794b38528 Mon Sep 17 00:00:00 2001 From: AngeD Date: Sun, 17 Sep 2023 00:27:10 +0200 Subject: [PATCH] feat: matrix --- matrix/.env | 10 ++++++++ matrix/compose.yaml | 60 +++++++++++++++++++++++++++++++++++++++++++++ matrix/install_site | 1 + matrix/nginx.conf | 30 +++++++++++++++++++++++ 4 files changed, 101 insertions(+) create mode 100644 matrix/.env create mode 100644 matrix/compose.yaml create mode 120000 matrix/install_site create mode 100644 matrix/nginx.conf diff --git a/matrix/.env b/matrix/.env new file mode 100644 index 0000000..7a3db70 --- /dev/null +++ b/matrix/.env @@ -0,0 +1,10 @@ +BASE_URL=matrix. +EMAIL= +POSTGRES_PASSWORD= + +PUID=1000 +PGID=1000 + +SYNAPSE_REPORT_STATS=no +POSTGRES_USER=matrix +POSTGRES_DB=matrix diff --git a/matrix/compose.yaml b/matrix/compose.yaml new file mode 100644 index 0000000..23f4382 --- /dev/null +++ b/matrix/compose.yaml @@ -0,0 +1,60 @@ +--- +services: + install_site: + build: install_site + environment: + - BASE_URL + - EMAIL + volumes: + - ./nginx.conf:/web/matrix.conf + - sites:/sites/ + - certs:/etc/letsencrypt/ + - certbotroot:/var/www/certbot/ + - /var/run/docker.sock:/var/run/docker.sock + + db: + image: docker.io/postgres:15 + restart: unless-stopped + volumes: + - db:/var/lib/postgresql/data/ + environment: + - POSTGRES_DB + - POSTGRES_USER + - POSTGRES_PASSWORD + + matrix: + image: docker.io/matrixdotorg/synapse:latest + restart: unless-stopped + volumes: + - config:/config/ + - data:/data/ + environment: + - SYNAPSE_SERVER_NAME=$BASE_URL + - SYNAPSE_REPORT_STATS + - SYNAPSE_CONFIG_DIR=/config + - SYNAPSE_DATA_DIR=/data + - POSTGRES_HOST=db + - UID=$PUID + - GID=$PGID + env_file: + - .env + networks: + - nginx + - default + depends_on: + - db + +volumes: + sites: + external: true + certs: + external: true + certbotroot: + external: true + db: + config: + data: + +networks: + nginx: + external: true diff --git a/matrix/install_site b/matrix/install_site new file mode 120000 index 0000000..565584b --- /dev/null +++ b/matrix/install_site @@ -0,0 +1 @@ +../nginx/install_site \ No newline at end of file diff --git a/matrix/nginx.conf b/matrix/nginx.conf new file mode 100644 index 0000000..3d3e598 --- /dev/null +++ b/matrix/nginx.conf @@ -0,0 +1,30 @@ +server { + listen 80; + listen [::]:80; + server_name $BASE_URL; + + return 301 https://$host$request_uri; +} + +server { + listen 443 ssl; + listen [::]:443 ssl; + server_name $BASE_URL; + +# # For the federation port +# listen 8448 ssl default_server; +# listen [::]:8448 ssl default_server; + + ssl_certificate /etc/letsencrypt/live/$BASE_URL/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/$BASE_URL/privkey.pem; + + location ~ ^(/_matrix|/_synapse/client) { + proxy_pass http://matrix:8008; + + proxy_set_header X-Forwarded-For $remote_addr; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header Host $host; + client_max_body_size 50M; + proxy_http_version 1.1; + } +}