Add webserver configuration in preparation for cartman/wendy switch
Eelco Dolstra committed
Jun 7, 2013 at 13:59 UTC
54d4500ecf450210216ae858bc11e3252683ba6a
2 files changed
+301
-5
delft/delft-webserver.nix
new
+288
@@ -0,0 +1,288 @@
1
+{ config, pkgs, ... }:
2
+
3
+with pkgs.lib;
4
+
5
+let
6
+
7
+ zabbixMail = pkgs.writeScriptBin "zabbix-mail" ''
8
+ #!/bin/sh
9
+ set -e
10
+
11
+ export zabbixemailto="$1"
12
+ export zabbixsubject="$2"
13
+ export zabbixbody="$3"
14
+
15
+ ${pkgs.ssmtp}/sbin/sendmail -v $zabbixemailto <<EOF
16
+ Subject: $zabbixsubject
17
+ To: $zabbixemailto
18
+
19
+ $zabbixbody
20
+ EOF
21
+ '';
22
+
23
+ ZabbixApacheUpdater = pkgs.fetchsvn {
24
+ url = https://www.zulukilo.com/svn/pub/zabbix-apache-stats/trunk/fetch.py;
25
+ sha256 = "1q66x429wpqjqcmlsi3x37rkn95i55nj8ldzcrblnx6a0jnjgd2g";
26
+ rev = 94;
27
+ };
28
+
29
+ strategoxtVHostConfig =
30
+ { hostName = "strategoxt.org";
31
+ servedFiles = [
32
+ { urlPath = "/freenode.ver";
33
+ file = "/data/pt-wiki/pub/freenode.ver";
34
+ }
35
+ ];
36
+ extraSubservices = [
37
+ { function = import /etc/nixos/services/twiki;
38
+ startWeb = "Stratego/WebHome";
39
+ dataDir = "/data/pt-wiki/data";
40
+ pubDir = "/data/pt-wiki/pub";
41
+ twikiName = "Stratego/XT Wiki";
42
+ registrationDomain = "ewi.tudelft.nl";
43
+ }
44
+ ];
45
+ };
46
+
47
+ strategoxtSSLConfig =
48
+ { enableSSL = true;
49
+ sslServerCert = "/root/ssl-secrets/ssl-strategoxt-org.crt";
50
+ sslServerKey = "/root/ssl-secrets/ssl-strategoxt-org.key";
51
+ extraConfig =
52
+ ''
53
+ SSLCertificateChainFile /root/ssl-secrets/startssl-class1.pem
54
+ SSLCACertificateFile /root/ssl-secrets/startssl-ca.pem
55
+ '';
56
+ };
57
+
58
+in
59
+
60
+rec {
61
+ require = [ ];
62
+
63
+ services = {
64
+
65
+ httpd = {
66
+ enable = true;
67
+ multiProcessingModule = "worker";
68
+ logPerVirtualHost = true;
69
+ adminAddr = "e.dolstra@tudelft.nl";
70
+ hostName = "localhost";
71
+
72
+ extraModules = ["deflate"];
73
+ extraConfig =
74
+ ''
75
+ AddType application/nix-package .nixpkg
76
+
77
+ <Location /server-status>
78
+ SetHandler server-status
79
+ Allow from 127.0.0.1 # If using a remote host for monitoring replace 127.0.0.1 with its IP.
80
+ Order deny,allow
81
+ Deny from all
82
+ </Location>
83
+
84
+ ExtendedStatus On
85
+
86
+ StartServers 15
87
+ '';
88
+
89
+ phpOptions =
90
+ ''
91
+ #max_execution_time = 2
92
+ memory_limit = "128M"
93
+ max_input_time = 300
94
+ '';
95
+
96
+ virtualHosts = [
97
+
98
+ { # Catch-all site.
99
+ hostName = "old.nixos.org";
100
+ globalRedirect = "http://nixos.org/";
101
+ }
102
+
103
+ { hostName = "buildfarm.st.ewi.tudelft.nl";
104
+ documentRoot = cleanSource ./webroot;
105
+ enableUserDir = true;
106
+ extraSubservices = [
107
+ { function = import /etc/nixos/services/subversion;
108
+ urlPrefix = "";
109
+ toplevelRedirect = false;
110
+ dataDir = "/data/subversion";
111
+ notificationSender = "svn@buildfarm.st.ewi.tudelft.nl";
112
+ organisation = {
113
+ name = "Software Engineering Research Group, TU Delft";
114
+ url = http://www.st.ewi.tudelft.nl/;
115
+ logo = "/serg-logo.png";
116
+ };
117
+ } /*
118
+ { function = import /etc/nixos/services/subversion;
119
+ id = "ptg";
120
+ urlPrefix = "/ptg";
121
+ dataDir = "/data/subversion-ptg";
122
+ notificationSender = "svn@buildfarm.st.ewi.tudelft.nl";
123
+ organisation = {
124
+ name = "Software Engineering Research Group, TU Delft";
125
+ url = http://www.st.ewi.tudelft.nl/;
126
+ logo = "/serg-logo.png";
127
+ };
128
+ } */
129
+ { serviceType = "zabbix";
130
+ urlPrefix = "/zabbix";
131
+ }
132
+ ];
133
+ servedDirs = [
134
+ { urlPath = "/releases";
135
+ dir = "/data/webserver/dist";
136
+ }
137
+ ];
138
+ }
139
+
140
+ strategoxtVHostConfig
141
+
142
+ (strategoxtVHostConfig // strategoxtSSLConfig)
143
+
144
+ { hostName = "www.strategoxt.org";
145
+ serverAliases = ["www.stratego-language.org"];
146
+ globalRedirect = "http://strategoxt.org/";
147
+ }
148
+
149
+ { hostName = "svn.strategoxt.org";
150
+ globalRedirect = "https://svn.strategoxt.org/";
151
+ }
152
+
153
+ ( strategoxtSSLConfig //
154
+ { hostName = "svn.strategoxt.org";
155
+ extraSubservices = [
156
+ { function = import /etc/nixos/services/subversion;
157
+ id = "strategoxt";
158
+ urlPrefix = "";
159
+ dataDir = "/data/subversion-strategoxt";
160
+ notificationSender = "svn@svn.strategoxt.org";
161
+ organisation = {
162
+ name = "Stratego/XT";
163
+ url = http://strategoxt.org/;
164
+ logo = http://strategoxt.org/pub/Stratego/StrategoLogo/StrategoLogoTextlessWhite-100px.png;
165
+ };
166
+ }
167
+ ];
168
+ })
169
+
170
+ { hostName = "program-transformation.org";
171
+ serverAliases = ["www.program-transformation.org"];
172
+ extraSubservices = [
173
+ { function = import /etc/nixos/services/twiki;
174
+ startWeb = "Transform/WebHome";
175
+ dataDir = "/data/pt-wiki/data";
176
+ pubDir = "/data/pt-wiki/pub";
177
+ twikiName = "Program Transformation Wiki";
178
+ registrationDomain = "ewi.tudelft.nl";
179
+ }
180
+ ];
181
+ }
182
+
183
+ { hostName = "releases.strategoxt.org";
184
+ documentRoot = "/data/webserver/dist/strategoxt2";
185
+ }
186
+
187
+ { hostName = "syntax-definition.org";
188
+ serverAliases = ["www.syntax-definition.org"];
189
+ extraSubservices = [
190
+ { function = import /etc/nixos/services/twiki;
191
+ startWeb = "Sdf/WebHome";
192
+ dataDir = "/data/pt-wiki/data";
193
+ pubDir = "/data/pt-wiki/pub";
194
+ twikiName = "Syntax Definition Wiki";
195
+ registrationDomain = "ewi.tudelft.nl";
196
+ }
197
+ ];
198
+ }
199
+
200
+ { hostName = "hydra.nixos.org";
201
+ logFormat = ''"%h %l %u %t \"%r\" %>s %b %D"'';
202
+ extraConfig = ''
203
+ TimeOut 900
204
+
205
+ <Proxy *>
206
+ Order deny,allow
207
+ Allow from all
208
+ </Proxy>
209
+
210
+ ProxyRequests Off
211
+ ProxyPreserveHost On
212
+ ProxyPass / http://lucifer:3000/ retry=5 disablereuse=on
213
+ ProxyPassReverse / http://lucifer:3000/
214
+
215
+ <Location />
216
+ SetOutputFilter DEFLATE
217
+ BrowserMatch ^Mozilla/4\.0[678] no-gzip\
218
+ BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html
219
+ SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary
220
+ SetEnvIfNoCase Request_URI /api/ no-gzip dont-vary
221
+ SetEnvIfNoCase Request_URI /download/ no-gzip dont-vary
222
+ </Location>
223
+
224
+ '';
225
+ }
226
+
227
+ { hostName = "hydra-test.nixos.org";
228
+ logFormat = ''"%h %l %u %t \"%r\" %>s %b %D"'';
229
+ extraConfig = ''
230
+ <Proxy *>
231
+ Order deny,allow
232
+ Allow from all
233
+ </Proxy>
234
+
235
+ ProxyRequests Off
236
+ ProxyPreserveHost On
237
+ ProxyPass / http://wendy:4000/ retry=5 disablereuse=off
238
+ ProxyPassReverse / http://wendy:4000/
239
+ '';
240
+ }
241
+
242
+ { hostName = "planet.strategoxt.org";
243
+ serverAliases = ["planet.stratego.org"];
244
+ documentRoot = "/home/karltk/public_html/planet";
245
+ }
246
+
247
+ { hostName = "mturk.nixos.org";
248
+ extraConfig = ''
249
+ <Proxy *>
250
+ Order deny,allow
251
+ Allow from all
252
+ </Proxy>
253
+
254
+ ProxyRequests Off
255
+ ProxyPreserveHost On
256
+ ProxyPass / http://wendy/~mturk/ retry=5
257
+ ProxyPassReverse / http://wendy/~mturk/
258
+ '';
259
+ }
260
+
261
+ { hostName = "mturk-view.nixos.org";
262
+ extraConfig = ''
263
+ Redirect permanent / http://nixos.org/mturk/
264
+ '';
265
+ }
266
+
267
+ { hostName = "mturk-view-sandbox.nixos.org";
268
+ extraConfig = ''
269
+ Redirect permanent / http://nixos.org/mturk-sandbox/
270
+ '';
271
+ }
272
+
273
+ ];
274
+ };
275
+
276
+ zabbixAgent.enable = true;
277
+
278
+ zabbixServer.enable = true;
279
+ zabbixServer.dbServer = "wendy";
280
+ zabbixServer.dbPassword = import ./zabbix-password.nix;
281
+
282
+ flashpolicyd.enable = true;
283
+
284
+ };
285
+
286
+ environment.systemPackages = [ zabbixMail ];
287
+
288
+}
delft/wendy.nix
+13
-5
@@ -1,7 +1,6 @@
1
{ config, pkgs, ... }:
2
-
2
{
4
- require = [ ./build-machines-dell-r815.nix ];
3
+ require = [ ./build-machines-dell-r815.nix ./delft-webserver.nix ];
4
5
fileSystems."/backup" =
6
{ device = "130.161.158.5:/dxs/users4/group/buildfarm";
@@ -58,7 +57,7 @@
57
58
services.postgresqlBackup = {
59
enable = true;
61
- databases = [ "hydra" "jira" "mediawiki" ];
60
+ databases = [ "hydra" "jira" ];
61
};
62
63
services.postgresql = {
@@ -82,8 +81,6 @@
81
host all all 192.168.1.25/32 md5
82
host hydra hydra 192.168.1.26/32 md5
83
host hydra_test hydra 192.168.1.26/32 md5
85
- host mediawiki mediawiki 192.168.1.5/32 md5
86
- host mediawiki mediawiki 192.168.1.26/32 md5
84
host zabbix zabbix 192.168.1.5/32 md5
85
'';
86
};
@@ -107,4 +104,15 @@
104
];
105
106
networking.firewall.allowedTCPPorts = [ 80 3000 3001 4000 5432 ];
107
+
108
+
109
+ # Needed for the Nixpkgs mirror script.
110
+ environment.pathsToLink = [ "/libexec" ];
111
+ environment.systemPackages = [ pkgs.dnsmasq pkgs.duplicity ];
112
+
113
+ # Use cgroups to limit Apache's resources.
114
+ systemd.services.httpd.serviceConfig.CPUShares = 1000;
115
+ systemd.services.httpd.serviceConfig.MemoryLimit = "1500M";
116
+ systemd.services.httpd.serviceConfig.ControlGroupAttribute = [ "memory.memsw.limit_in_bytes 1500M" ];
117
+
118
}