tangled
alpha
login
or
join now
pyrox.dev
/
nixpkgs
0
fork
atom
lol
0
fork
atom
overview
issues
pulls
pipelines
Apache service module: allow compression
Wout Mertens
10 years ago
164f6ff2
ef721079
+30
-1
1 changed file
expand all
collapse all
unified
split
nixos
modules
services
web-servers
apache-httpd
default.nix
+30
-1
nixos/modules/services/web-servers/apache-httpd/default.nix
···
117
117
]
118
118
++ (if mainCfg.multiProcessingModule == "prefork" then [ "cgi" ] else [ "cgid" ])
119
119
++ optional enableSSL "ssl"
120
120
+
++ optional mainCfg.enableCompression "deflate"
120
121
++ extraApacheModules;
121
122
122
123
···
176
177
SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5:!EXP
177
178
'';
178
179
180
180
+
# From http://paulstamatiou.com/how-to-optimize-your-apache-site-with-mod-deflate/
181
181
+
compressConf = ''
182
182
+
SetOutputFilter DEFLATE
183
183
+
184
184
+
# Don't compress binaries
185
185
+
SetEnvIfNoCase Request_URI .(?:exe|t?gz|zip|iso|tar|bz2|sit|rar) no-gzip dont-vary
186
186
+
# Don't compress images
187
187
+
SetEnvIfNoCase Request_URI .(?:gif|jpe?g|jpg|ico|png) no-gzip dont-vary
188
188
+
# Don't compress PDFs
189
189
+
SetEnvIfNoCase Request_URI .pdf no-gzip dont-vary
190
190
+
# Don't compress flash files (only relevant if you host your own videos)
191
191
+
SetEnvIfNoCase Request_URI .flv no-gzip dont-vary
192
192
+
# Netscape 4.X has some problems
193
193
+
BrowserMatch ^Mozilla/4 gzip-only-text/html
194
194
+
# Netscape 4.06-4.08 have some more problems
195
195
+
BrowserMatch ^Mozilla/4.0[678] no-gzip
196
196
+
# MSIE masquerades as Netscape, but it is fine
197
197
+
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
198
198
+
# Make sure proxies don't deliver the wrong content
199
199
+
Header append Vary User-Agent env=!dont-vary
200
200
+
'';
179
201
180
202
mimeConf = ''
181
203
TypesConfig ${httpd}/conf/mime.types
···
351
373
${mimeConf}
352
374
${loggingConf}
353
375
${browserHacks}
376
376
+
${optionalString mainCfg.enableCompression compressConf}
354
377
355
378
Include ${httpd}/conf/extra/httpd-default.conf
356
379
Include ${httpd}/conf/extra/httpd-autoindex.conf
···
423
446
enable = mkOption {
424
447
type = types.bool;
425
448
default = false;
426
426
-
description = "Whether to enable the Apache HTTP Server.";
449
449
+
description = "Enable the Apache HTTP Server.";
427
450
};
428
451
429
452
package = mkOption {
···
585
608
example = 500;
586
609
description =
587
610
"Maximum number of httpd requests answered per httpd child (prefork), 0 means unlimited";
611
611
+
};
612
612
+
613
613
+
enableCompression = mkOption {
614
614
+
type = types.bool;
615
615
+
default = false;
616
616
+
description = "Enable compression of responses using mod_deflate.";
588
617
};
589
618
}
590
619