aboutsummaryrefslogtreecommitdiff
path: root/modules/services/web/default.nix
blob: fe97c0e9107f7a39bf472edbf740396f38a997e6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
{ config, ... }:
let
  fqdn = "synapse.${config.networking.domain}";
  baseUrl = "https://${fqdn}";
in
{
  networking.domain = "tdback.net";
  networking.firewall.allowedTCPPorts = [
    80
    443
  ];

  services.caddy = {
    enable = true;
    virtualHosts = {
      ${config.networking.domain}.extraConfig = ''
        handle /.well-known/matrix/server {
          Content-Type application/json
          Access-Control-Allow-Origin *
          respond `{"m.server": "${fqdn}:443"}`
        }

        handle /.well-known/matrix/client {
          Content-Type application/json
          Access-Control-Allow-Origin *
          respond `{"m.homeserver": {"base_url": "${baseUrl}"}}`
        }

        root * /var/www/tdback.net/
        encode zstd gzip
        file_server
      '';
    };
  };
}