nixos/httpd: set modern default values for mpm and http2

This commit is contained in:
Aaron Andersen 2020-04-11 20:03:33 -04:00
parent 20f37a4430
commit ee030b121b
2 changed files with 13 additions and 13 deletions

View file

@ -41,9 +41,9 @@ let
"mime" "autoindex" "negotiation" "dir" "mime" "autoindex" "negotiation" "dir"
"alias" "rewrite" "alias" "rewrite"
"unixd" "slotmem_shm" "socache_shmcb" "unixd" "slotmem_shm" "socache_shmcb"
"mpm_${cfg.multiProcessingModule}" "mpm_${cfg.mpm}"
] ]
++ (if cfg.multiProcessingModule == "prefork" then [ "cgi" ] else [ "cgid" ]) ++ (if cfg.mpm == "prefork" then [ "cgi" ] else [ "cgid" ])
++ optional enableHttp2 "http2" ++ optional enableHttp2 "http2"
++ optional enableSSL "ssl" ++ optional enableSSL "ssl"
++ optional enableUserDir "userdir" ++ optional enableUserDir "userdir"
@ -264,7 +264,7 @@ let
PidFile ${runtimeDir}/httpd.pid PidFile ${runtimeDir}/httpd.pid
${optionalString (cfg.multiProcessingModule != "prefork") '' ${optionalString (cfg.mpm != "prefork") ''
# mod_cgid requires this. # mod_cgid requires this.
ScriptSock ${runtimeDir}/cgisock ScriptSock ${runtimeDir}/cgisock
''} ''}
@ -349,6 +349,7 @@ in
imports = [ imports = [
(mkRemovedOptionModule [ "services" "httpd" "extraSubservices" ] "Most existing subservices have been ported to the NixOS module system. Please update your configuration accordingly.") (mkRemovedOptionModule [ "services" "httpd" "extraSubservices" ] "Most existing subservices have been ported to the NixOS module system. Please update your configuration accordingly.")
(mkRemovedOptionModule [ "services" "httpd" "stateDir" ] "The httpd module now uses /run/httpd as a runtime directory.") (mkRemovedOptionModule [ "services" "httpd" "stateDir" ] "The httpd module now uses /run/httpd as a runtime directory.")
(mkRenamedOptionModule [ "services" "httpd" "multiProcessingModule" ] [ "services" "httpd" "mpm" ])
# virtualHosts options # virtualHosts options
(mkRemovedOptionModule [ "services" "httpd" "documentRoot" ] "Please define a virtual host using `services.httpd.virtualHosts`.") (mkRemovedOptionModule [ "services" "httpd" "documentRoot" ] "Please define a virtual host using `services.httpd.virtualHosts`.")
@ -544,20 +545,19 @@ in
''; '';
}; };
multiProcessingModule = mkOption { mpm = mkOption {
type = types.enum [ "event" "prefork" "worker" ]; type = types.enum [ "event" "prefork" "worker" ];
default = "prefork"; default = "event";
example = "worker"; example = "worker";
description = description =
'' ''
Multi-processing module to be used by Apache. Available Multi-processing module to be used by Apache. Available
modules are <literal>prefork</literal> (the default; modules are <literal>prefork</literal> (handles each
handles each request in a separate child process), request in a separate child process), <literal>worker</literal>
<literal>worker</literal> (hybrid approach that starts a (hybrid approach that starts a number of child processes
number of child processes each running a number of each running a number of threads) and <literal>event</literal>
threads) and <literal>event</literal> (a recent variant of (the default; a recent variant of <literal>worker</literal>
<literal>worker</literal> that handles persistent that handles persistent connections more efficiently).
connections more efficiently).
''; '';
}; };

View file

@ -137,7 +137,7 @@ in
http2 = mkOption { http2 = mkOption {
type = types.bool; type = types.bool;
default = false; default = true;
description = '' description = ''
Whether to enable HTTP 2. HTTP/2 is supported in all multi-processing modules that come with httpd. <emphasis>However, if you use the prefork mpm, there will Whether to enable HTTP 2. HTTP/2 is supported in all multi-processing modules that come with httpd. <emphasis>However, if you use the prefork mpm, there will
be severe restrictions.</emphasis> Refer to <link xlink:href="https://httpd.apache.org/docs/2.4/howto/http2.html#mpm-config"/> for details. be severe restrictions.</emphasis> Refer to <link xlink:href="https://httpd.apache.org/docs/2.4/howto/http2.html#mpm-config"/> for details.