|
@@ -1,6 +1,6 @@
|
1
|
1
|
#!/bin/bash
|
2
|
2
|
|
3
|
|
-set -euo pipefail
|
|
3
|
+set -eo pipefail
|
4
|
4
|
|
5
|
5
|
DOMAIN=$1
|
6
|
6
|
if [ -z ${DOMAIN} ]; then
|
|
@@ -94,7 +94,7 @@ PG_PASS=$(pwgen -s 28 -1)
|
94
|
94
|
sed -i "s|DOMAIN|${DOMAIN}|g" "${BASE_DIR}/docker-compose.yaml"
|
95
|
95
|
sed -i "s|PG_PASS|${PG_PASS}|g" "${BASE_DIR}/docker-compose.yaml"
|
96
|
96
|
|
97
|
|
-# Generate synapse file
|
|
97
|
+# Generate synapse config file
|
98
|
98
|
echo -e "Generating synapse file..\n"
|
99
|
99
|
docker compose run --rm -e SYNAPSE_SERVER_NAME=${DOMAIN} -e SYNAPSE_REPORT_STATS=yes synapse generate
|
100
|
100
|
|
|
@@ -111,6 +111,7 @@ cp /tmp/homeserver.yaml "${BASE_DIR}/config/synapse/homeserver.yaml"
|
111
|
111
|
|
112
|
112
|
# Configure User Directory and TURN
|
113
|
113
|
cat <<EOF >> "${BASE_DIR}/config/synapse/homeserver.yaml"
|
|
114
|
+public_baseurl: "https://${DOMAIN}"
|
114
|
115
|
user_directory:
|
115
|
116
|
enabled: true
|
116
|
117
|
search_all_users: true
|
|
@@ -121,6 +122,7 @@ turn_user_lifetime: 86400000
|
121
|
122
|
turn_shared_secret: "${TURN_STATIC_SECRET}"
|
122
|
123
|
turn_uris: [ "turn:${DOMAIN}?transport=udp" ]
|
123
|
124
|
suppress_key_server_warning: true
|
|
125
|
+enable_authenticated_media: False
|
124
|
126
|
retention:
|
125
|
127
|
enabled: true
|
126
|
128
|
default_policy:
|
|
@@ -158,14 +160,10 @@ server {
|
158
|
160
|
# Hardening
|
159
|
161
|
add_header Strict-Transport-Security "max-age=31536000; includeSubdomains; preload";
|
160
|
162
|
add_header Content-Security-Policy "default-src 'self' ${DOMAIN} http: https: data: blob: 'unsafe-inline' 'unsafe-eval'" always;
|
|
163
|
+ add_header X-XSS-Protection "1; mode=block";
|
|
164
|
+ add_header X-Content-Type-Options nosniff;
|
161
|
165
|
add_header X-Frame-Options "SAMEORIGIN";
|
162
|
166
|
|
163
|
|
- location /.well-known/matrix/client {
|
164
|
|
- default_type application/json;
|
165
|
|
- add_header Access-Control-Allow-Origin *;
|
166
|
|
- return 200 '{"m.homeserver": {"base_url": "https://${DOMAIN}"}, "org.matrix.msc3575.proxy": {"url": "https://${DOMAIN}"}}';
|
167
|
|
- }
|
168
|
|
-
|
169
|
167
|
# Admin panel
|
170
|
168
|
location /admin/ {
|
171
|
169
|
proxy_pass http://10.10.10.6/;
|
|
@@ -175,21 +173,23 @@ server {
|
175
|
173
|
proxy_http_version 1.1;
|
176
|
174
|
}
|
177
|
175
|
|
178
|
|
- # Sydent identity server
|
179
|
|
- location ~ ^(/_matrix/identity) {
|
180
|
|
- proxy_pass http://10.10.10.5:8090;
|
|
176
|
+ # Proxy for Synapse Admin Panel
|
|
177
|
+ location /_synapse/admin {
|
|
178
|
+ proxy_pass http://10.10.10.4:8008;
|
181
|
179
|
proxy_set_header X-Forwarded-For \$remote_addr;
|
182
|
180
|
proxy_set_header X-Forwarded-Proto \$scheme;
|
183
|
181
|
proxy_set_header Host \$host;
|
|
182
|
+ client_max_body_size 50M;
|
184
|
183
|
proxy_http_version 1.1;
|
185
|
184
|
}
|
186
|
185
|
|
187
|
|
- # Sliding Sync
|
188
|
|
- location ~ ^/(client/|_matrix/client/unstable/org.matrix.msc3575/sync) {
|
189
|
|
- proxy_pass http://10.10.10.7:8008;
|
|
186
|
+ # Sydent identity server
|
|
187
|
+ location ~ ^(/_matrix/identity) {
|
|
188
|
+ proxy_pass http://10.10.10.5:8090;
|
190
|
189
|
proxy_set_header X-Forwarded-For \$remote_addr;
|
191
|
190
|
proxy_set_header X-Forwarded-Proto \$scheme;
|
192
|
191
|
proxy_set_header Host \$host;
|
|
192
|
+ proxy_http_version 1.1;
|
193
|
193
|
}
|
194
|
194
|
|
195
|
195
|
# Synapse Backend
|
|
@@ -214,6 +214,12 @@ server {
|
214
|
214
|
proxy_http_version 1.1;
|
215
|
215
|
}
|
216
|
216
|
|
|
217
|
+ location /.well-known/matrix/client {
|
|
218
|
+ default_type application/json;
|
|
219
|
+ add_header Access-Control-Allow-Origin *;
|
|
220
|
+ return 200 '{"m.homeserver": {"base_url": "https://${DOMAIN}"}, "m.identity_server": {"base_url": "https://${DOMAIN}"}}';
|
|
221
|
+ }
|
|
222
|
+
|
217
|
223
|
# Element Frontend
|
218
|
224
|
location / {
|
219
|
225
|
# Element chat Container Network IP
|