blob: 17a08a622c6ea1522db740e4f81a60a3721d3fad (
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
77
78
79
80
81
82
83
84
85
86
87
88
|
{
config,
pkgs,
...
}: let
domain = "push.${config.customOps.domain.fqdn}";
port = 8082;
redisPort = 6369;
endpointPort = 443;
autopush = pkgs.autopush-rs;
in {
sops.secrets = {
"autopush/autoconnect" = {};
"autopush/autoendpoint" = {};
};
environment.systemPackages = [autopush];
services.redis.servers."autopush" = {
enable = true;
port = redisPort;
};
systemd.services = {
autopush-autoconnect = {
environment = {
AUTOCONNECT__DB_DSN = "redis://127.0.0.1:${builtins.toString redisPort}";
AUTOCONNECT__ENDPOINT_SCHEME = "https";
AUTOCONNECT__ENDPOINT_HOSTNAME = "updates.${domain}";
AUTOCONNECT__ENDPOINT_PORT = builtins.toString endpointPort;
AUTOCONNECT__ROUTER_HOSTNAME = "127.0.0.1";
};
wantedBy = ["multi-user.target"];
serviceConfig = {
EnvironmentFile = config.sops.secrets."autopush/autoconnect".path;
ExecStart = "${autopush}/bin/autoconnect";
};
};
autopush-autoendpoint = {
environment = {
AUTOEND__DB_DSN = "redis://127.0.0.1:${builtins.toString redisPort}";
AUTOEND__HOST = "127.0.0.1";
AUTOEND__PORT = builtins.toString port;
AUTOEND__ENDPOINT_URL = "https://updates.${domain}";
AUTOEND__HUMAN_LOGS = "true";
};
wantedBy = ["multi-user.target"];
serviceConfig = {
EnvironmentFile = config.sops.secrets."autopush/autoendpoint".path;
ExecStart = "${autopush}/bin/autoendpoint";
};
};
};
services.nginx.virtualHosts.${domain} = {
forceSSL = true;
enableACME = true;
locations."/" = {
proxyPass = "http://127.0.0.1:8080";
extraConfig = ''
proxy_http_version 1.1;
proxy_set_header Host $http_host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_connect_timeout 3m;
proxy_send_timeout 3m;
proxy_read_timeout 3m;
client_max_body_size 0;
proxy_buffering off;
proxy_request_buffering off;
proxy_redirect off;
'';
};
};
services.nginx.virtualHosts."updates.${domain}" = {
forceSSL = true;
enableACME = true;
locations."/" = {
proxyPass = "http://127.0.0.1:${builtins.toString port}";
extraConfig = ''
proxy_http_version 1.1;
proxy_set_header Host $http_host;
proxy_connect_timeout 3m;
proxy_send_timeout 3m;
proxy_read_timeout 3m;
client_max_body_size 0;
'';
};
};
}
|