blob: cc2eff305967d4af6166d4014cef925185e18f02 (
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
{config, ...}: let
domain = "push.${config.customOps.domain.fqdn}";
ntfyPort = "8080";
mollyPort = "8020";
nginxConf = ''
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_buffering off;
proxy_request_buffering off;
proxy_redirect off;
proxy_connect_timeout 3m;
proxy_send_timeout 3m;
proxy_read_timeout 3m;
client_max_body_size 0;
'';
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 = {
allowed_endpoints = [
"https://${domain}"
];
webserver = true;
};
environmentFile = config.sops.secrets."push/mollysocket".path;
};
services.nginx.virtualHosts.${domain} = {
forceSSL = true;
enableACME = true;
locations."/" = {
proxyPass = "http://127.0.0.1:${ntfyPort}";
extraConfig = ''
set $redirect_https "";
if ($request_method = GET) {
set $redirect_https "yes";
}
if ($request_uri ~* "^/([-_a-z0-9]{0,64}$|docs/|static/)") {
set $redirect_https "''${redirect_https}yes";
}
if ($redirect_https = "yesyes") {
return 302 https://$http_host$request_uri$is_args$query_string;
}
${nginxConf}
'';
};
};
services.nginx.virtualHosts."mollysocket.${domain}" = {
forceSSL = true;
enableACME = true;
locations."/" = {
proxyPass = "http://127.0.0.1:${mollyPort}";
extraConfig = nginxConf;
};
};
}
|