summaryrefslogtreecommitdiff
path: root/adonis/push/default.nix
blob: c60d1599bcb74bc249334ed72fca070d407dcb40 (plain) (blame)
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
{config, ...}: let
  domain = "push.${config.customOps.domain.fqdn}";
  ntfyPort = "8080";
  mollyPort = "8020";
in {
  sops.secrets = {
    "push/mollysocket" = {};
  };

  services.ntfy-sh = {
    enable = true;
    settings = {
      listen-http = ":${ntfyPort}";
      base-url = "https://${domain}";
      behind-proxy = true;
      auth-file = "/var/lib/ntfy-sh/user.db";
      auth-access = [
        "*:up*:write-only"
      ];
    };
  };

  services.mollysocket = {
    enable = true;
    settings = {
      host = "127.0.0.1";
      allowed_endpoints = [
        "https://${domain}"
      ];
    };
    environmentFile = config.sops.secrets."push/mollysocket".path;
  };

  services.nginx.virtualHosts.${domain} = {
    forceSSL = true;
    enableACME = true;
    locations."/" = {
      proxyPass = "http://127.0.0.1:${ntfyPort}";
      proxyWebsockets = true;
    };
  };

  services.nginx.virtualHosts."mollysocket.${domain}" = {
    forceSSL = true;
    enableACME = true;
    locations."/" = {
      proxyPass = "http://127.0.0.1:${mollyPort}";
      proxyWebsockets = true;
      extraConfig = ''
        proxy_set_header Host $host;
        proxy_set_header X-Original-URL $request_uri;
      '';
    };
  };
}