]> git.ekhem.eu.org Git - server.git/commitdiff
[matrix] Proxy communication through `nginx`.
authorJakub Czajka <jakub@ekhem.eu.org>
Sun, 27 Nov 2022 09:17:37 +0000 (10:17 +0100)
committerJakub Czajka <jakub@ekhem.eu.org>
Sun, 3 Dec 2023 21:03:23 +0000 (22:03 +0100)
This commit configures `nginx` to act as a reverse proxy for
matrix. `nginx` receives requests on ports 443 (client) and
8448 (other matrix instances) and forwards them to localhost:8008 for
matrix to process.

matrix/README
matrix/homeserver.yaml
nginx/README

index ba4206110390e18cc49a1e6d98560b02fa7901ec..7e9958161e124c0ea37ab5779d0f621d670908d2 100644 (file)
@@ -5,6 +5,16 @@ Open network for secure federated communication. `synapse` is a server
 implementing the matrix protocol. Servers connect to each other on port 8448
 (federation port). Clients connect to servers on port 443 (client port).
 
+DNS
+---
+
+matrix.<domain> CNAME <domain>
+
+SSL
+---
+
+Obtain a certificate with `certbot-nginx`.
+
 Files
 -----
 
index d842ab4d8b5b253038e71e9051794407ea47f664..1979e2823d403bef598d71180aeb2a4996aae847 100644 (file)
@@ -4,16 +4,16 @@
 # autogenerates on launch with your own SSL certificate + key pair
 # if you like.  Any required intermediary certificates can be
 # appended after the primary certificate in hierarchical order.
-tls_certificate_path: "/etc/matrix-synapse/homeserver.tls.crt"
+#tls_certificate_path: "/etc/matrix-synapse/homeserver.tls.crt"
 
 # PEM encoded private key for TLS
-tls_private_key_path: "/etc/matrix-synapse/homeserver.tls.key"
+#tls_private_key_path: "/etc/matrix-synapse/homeserver.tls.key"
 
 # PEM dh parameters for ephemeral keys
-tls_dh_params_path: "/etc/matrix-synapse/homeserver.tls.dh"
+#tls_dh_params_path: "/etc/matrix-synapse/homeserver.tls.dh"
 
 # Don't bind to the https port
-no_tls: False
+no_tls: True
 
 # List of allowed TLS fingerprints for this server to publish along
 # with the signing keys for this server. Other matrix servers that
@@ -234,65 +234,17 @@ federation_ip_range_blacklist:
 #   webclient: A web client. Requires web_client_location to be set.
 #
 listeners:
-  # Main HTTPS listener
-  # For when matrix traffic is sent directly to synapse.
-  -
-    # The port to listen for HTTPS requests on.
-    port: 8448
-
-    # Local addresses to listen on.
-    # On Linux and Mac OS, `::` will listen on all IPv4 and IPv6
-    # addresses by default. For most other OSes, this will only listen
-    # on IPv6.
-    bind_addresses:
-      - '::1'
-      - '127.0.0.1'
-      # - '::'
-      # - '0.0.0.0'
-
-    # This is a 'http' listener, allows us to specify 'resources'.
-    type: http
-
-    tls: true
-
-    # Use the X-Forwarded-For (XFF) header as the client IP and not the
-    # actual client IP.
-    x_forwarded: false
-
-    # List of HTTP resources to serve on this listener.
-    resources:
-      -
-        # List of resources to host on this listener.
-        names:
-          - client     # The client-server APIs, both v1 and v2
-
-        # Should synapse compress HTTP responses to clients that support it?
-        # This should be disabled if running synapse behind a load balancer
-        # that can do automatic compression.
-        compress: true
-
-      - names: [federation]  # Federation APIs
-        compress: false
-
-    # optional list of additional endpoints which can be loaded via
-    # dynamic modules
-    # additional_resources:
-    #   "/_matrix/my/custom/endpoint":
-    #     module: my_module.CustomRequestHandler
-    #     config: {}
-
   # Unsecure HTTP listener,
   # For when matrix traffic passes through loadbalancer that unwraps TLS.
   - port: 8008
     tls: false
     bind_addresses:
-      - '::1'
       - '127.0.0.1'
       # - '::'
       # - '0.0.0.0'
     type: http
 
-    x_forwarded: false
+    x_forwarded: true
 
     resources:
       - names: [client]
index 7817786ef4872a85500986531197ceec6ce0f621..3c462c5d36e95a89b918f83ea805bb17452c8988 100644 (file)
@@ -9,8 +9,9 @@ Files
 
 nginx
 |
-|-> nginx.conf -- /etc/nginx/ :: Main configuration.
-`-> mime.types -- /etc/nginx/ :: Available mime types.
+|-> nginx.conf               -- /etc/nginx/ :: Main configuration.
+|-> mime.types               -- /etc/nginx/ :: Available mime types.
+`-> matrix.<domain>.template -- /etc/nginx/sites-available.
 
 SSL
 ---
@@ -33,3 +34,13 @@ Install
 ```
 $ apt install nginx
 ```
+
+Sites
+-----
+
+Substitute `<...>` patterns in `*.template` files. Create symbolic links for
+files in /etc/nginx/sites-available.
+
+```
+$ ln -s /etc/nginx/sites-available/{...} /etc/nginx/sites-enabled
+```