summaryrefslogtreecommitdiff
path: root/os/srv/ntfy.nix
blob: 1417c81004c3b69954bd3266b062cf74ce17bd6b (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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
{
  config,
  lib,
  masterDomain,
  ...
}:
let
  cfg = config.os.srv.ntfy;
in
{
  options.os.srv.ntfy = {
    enable = lib.mkEnableOption "enables ntfy";
    proxyConfig = lib.mkOption {
      type = lib.types.attrs;
      default = { };
    };
  };
  config = lib.mkIf cfg.enable {
    services.ntfy-sh = {
      enable = true;
      settings = {
        base-url = "https://ntfy.${masterDomain}";

        listen-http = "127.0.0.1:2586";

        cache-file = "/var/lib/ntfy/cache.db";
        cache-duration = "72h";

        attachment-cache-dir = "/var/lib/ntfy/attachments";
        attachment-total-size-limit = "5G";
        attachment-file-size-limit = "15M";
        attachment-expiry-duration = "3h";

        behind-proxy = true;
      };
    };

    os.srv.ntfy.proxyConfig = {
      "uptime-kuma.${masterDomain}" = {
        enableACME = true;
        forceSSL = true;

        locations."/" = {
          proxyPass = "http://${config.os.core.network.ips.vm2-gateway}:3001";
          extraConfig = ''
            proxy_set_header Connection "";
            proxy_connect_timeout 1m;
            proxy_send_timeout 1m;
            proxy_read_timeout 24h;

            proxy_buffering off;
            proxy_request_buffering off;
            chunked_transfer_encoding on;
          '';
        };
      };
    };
  };
}