Allow httpd subservices to set the document root

Only the main service OR one of the subservices can set the document
root. This is used by mediawiki when it is hosted at the root of the
vhost.
This commit is contained in:
Shea Levy 2014-02-25 07:44:45 -05:00
parent ec09c7d34e
commit 0d4a9e3aa6
2 changed files with 10 additions and 3 deletions

View File

@ -63,6 +63,7 @@ let
enablePHP = false;
phpOptions = "";
options = {};
documentRoot = null;
};
res = defaults // svcFunction { inherit config pkgs serverInfo php; };
in res;
@ -188,7 +189,11 @@ let
subservices = callSubservices serverInfo cfg.extraSubservices;
documentRoot = if cfg.documentRoot != null then cfg.documentRoot else
maybeDocumentRoot = fold (svc: acc:
if acc == null then svc.documentRoot else assert svc.documentRoot == null; acc
) null ([ cfg ] ++ subservices);
documentRoot = if maybeDocumentRoot != null then maybeDocumentRoot else
pkgs.runCommand "empty" {} "ensureDir $out";
documentRootConf = ''
@ -240,7 +245,7 @@ let
${robotsConf}
${if isMainServer || cfg.documentRoot != null then documentRootConf else ""}
${if isMainServer || maybeDocumentRoot != null then documentRootConf else ""}
${if cfg.enableUserDir then ''

View File

@ -126,7 +126,7 @@ in
</Directory>
''}
Alias ${config.urlPrefix} ${mediawikiRoot}
${optionalString (config.urlPrefix != "") "Alias ${config.urlPrefix} ${mediawikiRoot}"}
<Directory ${mediawikiRoot}>
Order allow,deny
@ -139,6 +139,8 @@ in
''}
'';
documentRoot = if config.urlPrefix == "" then mediawikiRoot else null;
enablePHP = true;
options = {