blob: d11fc80afa51117d23f9a533db7c765ba599898c (
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
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
|
{...}: let
# rootDomain = config.networking.domain;
rootDomain = "bensima.com";
ports = import ./Ports.nix;
in {
imports = [./Gmnisrv.nix];
networking.firewall = {
allowedTCPPorts = [
ports.ssh
ports.git
ports.http
ports.https
ports.sabten
ports.gemini
ports.radicale
ports.znc
ports.gerrit-ssh
];
};
users.users.nginx.extraGroups = ["acme"];
services = {
libreddit = {
enable = true;
address = "127.0.0.1";
openFirewall = true;
port = ports.libreddit;
};
invidious = {
enable = true;
database.createLocally = true;
domain = "youtube.${rootDomain}";
nginx.enable = false; # do this myself, below
port = ports.invidious;
};
gmnisrv = {
enable = false;
listen = "0.0.0.0:${toString ports.gemini} [::]:${toString ports.gemini}";
settings = {
":tls" = {store = "/var/lib/gmnisrv";};
"bsima.me" = {"root" = "/var/web/ben";};
"${rootDomain}" = {
"root" = "/var/web/ben";
"cgi" = "on";
};
};
};
nginx = {
enable = true;
recommendedGzipSettings = true;
recommendedOptimisation = true;
recommendedProxySettings = true;
recommendedTlsSettings = true;
statusPage = true;
user = "nginx";
group = "nginx";
# Add PHP configuration for Monica
appendHttpConfig = ''
# PHP FastCGI configuration for Monica
upstream php-handler {
server unix:/run/phpfpm/monica.sock;
}
'';
virtualHosts = {
${rootDomain} = {
serverName = rootDomain;
forceSSL = true;
enableACME = true;
serverAliases = [
"www.simatime.com"
"simatime.com"
"www.bsima.me"
"bsima.me"
"mail.bensima.com"
];
locations = {
# nostr nip-5 verification
#"/.well-known/nostr.json".return = "200 '${
# builtins.toJSON {
# names.bensima = "2fa4b9ba71b6dab17c4723745bb7850dfdafcb6ae1a8642f76f9c64fa5f43436";
# }
#}'";
"/" = {
root = "/var/web/ben";
index = "index.html index.htm";
extraConfig = ''
autoindex on;
'';
};
# serve /~$USER paths, yeah i'm the only user, but whatever this
# trick might be useful someday
"~ ^/~(.+?)(/.*)?$" = {
alias = "/var/web/$1$2";
index = "index.html index.htm";
extraConfig = ''
autoindex on;
'';
};
};
};
"hoogle.${rootDomain}" = {
locations."/".proxyPass = "http://${ports.bensIp}:${toString ports.hoogle}";
forceSSL = true;
useACMEHost = rootDomain;
};
"tv.${rootDomain}" = {
locations."/".proxyPass = "http://tityos.feralhosting.com:50393";
forceSSL = true;
useACMEHost = rootDomain;
};
"youtube.${rootDomain}" = {
locations."/".proxyPass = "http://localhost:${toString ports.invidious}";
forceSSL = true;
useACMEHost = rootDomain;
};
"www.youtube.${rootDomain}" = {
forceSSL = true;
useACMEHost = rootDomain;
globalRedirect = "youtube.${rootDomain}";
};
"m.youtube.${rootDomain}" = {
forceSSL = true;
useACMEHost = rootDomain;
globalRedirect = "youtube.${rootDomain}";
};
"music.${rootDomain}" = {
forceSSL = true;
useACMEHost = rootDomain;
locations."/".proxyPass = "http://localhost:${toString ports.botamusique}";
};
"nostr.${rootDomain}" = {
forceSSL = true;
useACMEHost = rootDomain;
locations."/" = {
proxyPass = "http://localhost:${toString ports.nostr-relay}";
extraConfig = ''
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Host $host;
'';
};
};
"jupyter.${rootDomain}" = {
forceSSL = true;
useACMEHost = rootDomain;
locations = {
"/" = {
proxyPass = "http://${ports.bensIp}:${toString ports.jupyter}";
proxyWebsockets = true;
extraConfig = ''
proxy_buffering off;
proxy_read_timeout 86400;
'';
};
"/(api/kernels/[^/]+/channels|terminals/websocket)/" = {
proxyPass = "http://${ports.bensIp}:${toString ports.jupyter}";
proxyWebsockets = true;
};
};
};
};
};
};
security.acme.certs.${rootDomain} = {
group = "nginx";
# This must contain all of the other domains we host
extraDomainNames =
["simatime.com" "www.simatime.com" "bsima.me" "www.bsima.me"]
++ map (sub: "${sub}.${rootDomain}") [
"tv"
"hoogle"
"cal"
"jupyter"
"git"
"monica"
# xmpp stuff
"upload"
"conference"
];
};
}
|