From 5717e1bd2f4a0611fd1ca28282fe8de405dac807 Mon Sep 17 00:00:00 2001 From: ange Date: Wed, 1 May 2024 16:56:58 +0200 Subject: [PATCH 1/5] test --- .env | 2 +- homeserver.yaml | 6 ++---- manifests/bin/deploy.sh | 3 ++- manifests/bin/prod.sh | 4 ---- manifests/{prod => common}/delegation.yaml | 12 +++++++++--- new_user.sh | 2 +- 6 files changed, 15 insertions(+), 14 deletions(-) rename manifests/{prod => common}/delegation.yaml (84%) diff --git a/.env b/.env index 5d73f95..96449e9 100644 --- a/.env +++ b/.env @@ -1,5 +1,5 @@ PROD_URL=matrix.gmoker.com -PUBLIC_URL=gmoker.com +SERVER_NAME=test.k8s.gmoker.com IMAGEAPP=ghcr.io/element-hq/synapse:v1.106.0 TURN_URL=turn.test.gmoker.com diff --git a/homeserver.yaml b/homeserver.yaml index cb525d5..823f329 100644 --- a/homeserver.yaml +++ b/homeserver.yaml @@ -1,5 +1,5 @@ -server_name: "$BASE_URL" -public_baseurl: "https://$PUBLIC_URL" +server_name: "$SERVER_NAME" +public_baseurl: "https://$BASE_URL" pid_file: /homeserver.pid web_client: false soft_file_limit: 0 @@ -91,5 +91,3 @@ password_config: enabled: true encryption_enabled_by_default_for_room_type: "all" - -serve_server_wellknown: true diff --git a/manifests/bin/deploy.sh b/manifests/bin/deploy.sh index dc78e44..31c4fac 100755 --- a/manifests/bin/deploy.sh +++ b/manifests/bin/deploy.sh @@ -51,6 +51,7 @@ kcreatecm synapse-config \ --from-file=homeserver.yaml=<(envsubst "$(env | xargs printf '$%s ')" < homeserver.yaml) \ --from-file=log.config=<(envsubst "$(env | xargs printf '$%s ')" < log.config) -kapply common/keys.yaml common/app.yaml +kapply common/keys.yaml common/app.yaml common/delegation.yaml +kubectl rollout restart deployment delegation kubectl rollout restart statefulset app diff --git a/manifests/bin/prod.sh b/manifests/bin/prod.sh index bbcd0b9..db50906 100755 --- a/manifests/bin/prod.sh +++ b/manifests/bin/prod.sh @@ -4,7 +4,3 @@ export NB_REPLICAS=1 . ./manifests/bin/deploy.sh - -kapply prod/delegation.yaml - -kubectl rollout restart deployment delegation diff --git a/manifests/prod/delegation.yaml b/manifests/common/delegation.yaml similarity index 84% rename from manifests/prod/delegation.yaml rename to manifests/common/delegation.yaml index 42308b7..79538ef 100644 --- a/manifests/prod/delegation.yaml +++ b/manifests/common/delegation.yaml @@ -10,9 +10,9 @@ spec: tls: - secretName: tls-delegation hosts: - - "$PUBLIC_URL" + - "$SERVER_NAME" rules: - - host: "$PUBLIC_URL" + - host: "$SERVER_NAME" http: paths: - path: /.well-known/matrix/server @@ -53,11 +53,17 @@ data: server { listen 80; + location /.well-known/matrix/server { + default_type application/json; + add_header Access-Control-Allow-Origin *; + + return 200 '{"m.server": "$BASE_URL:443"}' + } location /.well-known/matrix/client { default_type application/json; add_header Access-Control-Allow-Origin *; - return 200 '{"m.homeserver": { "base_url": "https://$BASE_URL" }}'; + return 200 '{"m.homeserver": {"base_url": "https://$BASE_URL"}}'; } } --- diff --git a/new_user.sh b/new_user.sh index 93e8ca0..5699151 100755 --- a/new_user.sh +++ b/new_user.sh @@ -1,3 +1,3 @@ #!/bin/bash -e -kubectl exec -it -n synapse svc/app -- register_new_matrix_user -c /config/homeserver.yaml +kubectl exec -it svc/app -- register_new_matrix_user -c /config/homeserver.yaml From 8f806cc0f1d4cd61c7ea561027e7a68bfd2dccb8 Mon Sep 17 00:00:00 2001 From: ange Date: Wed, 1 May 2024 16:58:31 +0200 Subject: [PATCH 2/5] fix: missing ; --- manifests/common/delegation.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/common/delegation.yaml b/manifests/common/delegation.yaml index 79538ef..1eb77ca 100644 --- a/manifests/common/delegation.yaml +++ b/manifests/common/delegation.yaml @@ -57,7 +57,7 @@ data: default_type application/json; add_header Access-Control-Allow-Origin *; - return 200 '{"m.server": "$BASE_URL:443"}' + return 200 '{"m.server": "$BASE_URL:443"}'; } location /.well-known/matrix/client { default_type application/json; From 6790ccf7737fb95dbdb1ce0b0a0b808ec56cf9a4 Mon Sep 17 00:00:00 2001 From: ange Date: Wed, 1 May 2024 16:59:37 +0200 Subject: [PATCH 3/5] fix: /.well-known/matrix/server > svc/delegation --- manifests/common/delegation.yaml | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/manifests/common/delegation.yaml b/manifests/common/delegation.yaml index 1eb77ca..fe5dfd6 100644 --- a/manifests/common/delegation.yaml +++ b/manifests/common/delegation.yaml @@ -15,15 +15,8 @@ spec: - host: "$SERVER_NAME" http: paths: - - path: /.well-known/matrix/server - pathType: Exact - backend: - service: - name: app - port: - name: http - - path: /.well-known/matrix/client - pathType: Exact + - path: /.well-known/matrix/ + pathType: Prefix backend: service: name: delegation From 8ec0961c7375f60941a3baa37bb351a02dc2e0e2 Mon Sep 17 00:00:00 2001 From: ange Date: Wed, 1 May 2024 17:03:42 +0200 Subject: [PATCH 4/5] feat: SERVER_NAME=gmoker.com --- .env | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.env b/.env index 96449e9..5df369c 100644 --- a/.env +++ b/.env @@ -1,5 +1,5 @@ PROD_URL=matrix.gmoker.com -SERVER_NAME=test.k8s.gmoker.com +SERVER_NAME=gmoker.com IMAGEAPP=ghcr.io/element-hq/synapse:v1.106.0 TURN_URL=turn.test.gmoker.com From d2ba010dcbe8aaf364b3157d5351b425eea1a6b5 Mon Sep 17 00:00:00 2001 From: ange Date: Thu, 2 May 2024 17:31:54 +0200 Subject: [PATCH 5/5] style: reorder listeners entries --- .gitea/workflows/deploy.yaml | 2 +- homeserver.yaml | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/.gitea/workflows/deploy.yaml b/.gitea/workflows/deploy.yaml index 7cea4cc..f6d29c0 100644 --- a/.gitea/workflows/deploy.yaml +++ b/.gitea/workflows/deploy.yaml @@ -7,7 +7,7 @@ jobs: - uses: actions/checkout@v1 - name: setup env run: | - . ./.env + . ./.env || true if [ "${{ gitea.ref_name }}" == prod ] && [ -n "$PROD_URL" ]; then BASE_URL="$PROD_URL" else diff --git a/homeserver.yaml b/homeserver.yaml index 823f329..6073075 100644 --- a/homeserver.yaml +++ b/homeserver.yaml @@ -8,14 +8,12 @@ log_config: "/config/log.config" listeners: - port: 8008 tls: false - bind_addresses: ['::'] type: http - x_forwarded: false + x_forwarded: true + bind_addresses: ['::'] resources: - - names: [client] + - names: [client, federation] compress: true - - names: [federation] - compress: false database: name: "psycopg2"