* Statically check whether the generated httpd.conf is correct.
* Option `noUserDir' -> `enableUserDir', negatives are bad :-) svn path=/nixos/trunk/; revision=9927
This commit is contained in:
parent
6f5da72337
commit
4ef15fc095
@ -929,10 +929,32 @@
|
|||||||
";
|
";
|
||||||
};
|
};
|
||||||
|
|
||||||
noUserDir = mkOption {
|
enableUserDir = mkOption {
|
||||||
default = true;
|
default = false;
|
||||||
description = "
|
description = "
|
||||||
Set to false to let users to publish ~/public_html as /~user.
|
Whether to enable serving <filename>~/public_html</filename> as
|
||||||
|
<literal>/~<replaceable>username</replaceable></literal>.
|
||||||
|
";
|
||||||
|
};
|
||||||
|
|
||||||
|
documentRoot = mkOption {
|
||||||
|
default = null;
|
||||||
|
example = "/data/webserver/docs";
|
||||||
|
description = "
|
||||||
|
The path of Apache's document root directory. If left undefined,
|
||||||
|
an empty directory in the Nix store will be used as root.
|
||||||
|
";
|
||||||
|
};
|
||||||
|
|
||||||
|
servedDirs = mkOption {
|
||||||
|
default = [];
|
||||||
|
example = [
|
||||||
|
{ urlPath = "/nix";
|
||||||
|
dir = "/home/eelco/Dev/nix-homepage";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
description = "
|
||||||
|
This option provides a simple way to serve static directories.
|
||||||
";
|
";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -9,7 +9,8 @@ let
|
|||||||
httpd = pkgs.apacheHttpd;
|
httpd = pkgs.apacheHttpd;
|
||||||
|
|
||||||
|
|
||||||
documentRoot = "/etc";
|
documentRoot = if cfg.documentRoot != null then cfg.documentRoot else
|
||||||
|
pkgs.runCommand "empty" {} "ensureDir $out";
|
||||||
|
|
||||||
|
|
||||||
# Names of modules from ${httpd}/modules that we want to load.
|
# Names of modules from ${httpd}/modules that we want to load.
|
||||||
@ -138,12 +139,24 @@ let
|
|||||||
in pkgs.lib.concatStrings (map f apacheModules)
|
in pkgs.lib.concatStrings (map f apacheModules)
|
||||||
}
|
}
|
||||||
|
|
||||||
# !!! is this a good idea?
|
${if cfg.enableUserDir then ''
|
||||||
UseCanonicalName Off
|
|
||||||
|
|
||||||
ServerSignature On
|
UserDir public_html
|
||||||
|
|
||||||
${if cfg.noUserDir then "" else "UserDir public_html"}
|
<Directory "/home/*/public_html">
|
||||||
|
AllowOverride FileInfo AuthConfig Limit Indexes
|
||||||
|
Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
|
||||||
|
<Limit GET POST OPTIONS>
|
||||||
|
Order allow,deny
|
||||||
|
Allow from all
|
||||||
|
</Limit>
|
||||||
|
<LimitExcept GET POST OPTIONS>
|
||||||
|
Order deny,allow
|
||||||
|
Deny from all
|
||||||
|
</LimitExcept>
|
||||||
|
</Directory>
|
||||||
|
|
||||||
|
'' else ""}
|
||||||
|
|
||||||
AddHandler type-map var
|
AddHandler type-map var
|
||||||
|
|
||||||
@ -156,6 +169,7 @@ let
|
|||||||
${loggingConf}
|
${loggingConf}
|
||||||
${browserHacks}
|
${browserHacks}
|
||||||
|
|
||||||
|
Include ${httpd}/conf/extra/httpd-default.conf
|
||||||
Include ${httpd}/conf/extra/httpd-autoindex.conf
|
Include ${httpd}/conf/extra/httpd-autoindex.conf
|
||||||
Include ${httpd}/conf/extra/httpd-multilang-errordoc.conf
|
Include ${httpd}/conf/extra/httpd-multilang-errordoc.conf
|
||||||
Include ${httpd}/conf/extra/httpd-languages.conf
|
Include ${httpd}/conf/extra/httpd-languages.conf
|
||||||
@ -168,6 +182,18 @@ let
|
|||||||
</Directory>
|
</Directory>
|
||||||
|
|
||||||
${documentRootConf}
|
${documentRootConf}
|
||||||
|
|
||||||
|
${
|
||||||
|
let makeDirConf = elem: ''
|
||||||
|
Alias ${elem.urlPath} ${elem.dir}/
|
||||||
|
<Directory ${elem.dir}>
|
||||||
|
Order allow,deny
|
||||||
|
Allow from all
|
||||||
|
AllowOverride None
|
||||||
|
</Directory>
|
||||||
|
'';
|
||||||
|
in pkgs.lib.concatStrings (map makeDirConf cfg.servedDirs)
|
||||||
|
}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
|
||||||
@ -188,6 +214,10 @@ in
|
|||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
# Statically verify the syntactic correctness of the generated
|
||||||
|
# httpd.conf.
|
||||||
|
buildHook = "${httpd}/bin/httpd -f ${httpdConf} -t";
|
||||||
|
|
||||||
job = ''
|
job = ''
|
||||||
description "Apache HTTPD"
|
description "Apache HTTPD"
|
||||||
|
|
||||||
|
@ -17,7 +17,6 @@ let
|
|||||||
logDir = cfg.logDir;
|
logDir = cfg.logDir;
|
||||||
stateDir = cfg.stateDir;
|
stateDir = cfg.stateDir;
|
||||||
enableSSL = false;
|
enableSSL = false;
|
||||||
noUserDir = cfg.noUserDir;
|
|
||||||
extraDirectories = cfg.extraDirectories + extraConfig;
|
extraDirectories = cfg.extraDirectories + extraConfig;
|
||||||
|
|
||||||
startingDependency = if config.services.gw6c.enable then "gw6c" else "network-interfaces";
|
startingDependency = if config.services.gw6c.enable then "gw6c" else "network-interfaces";
|
||||||
@ -29,7 +28,8 @@ let
|
|||||||
|
|
||||||
inherit hostName httpPort httpsPort
|
inherit hostName httpPort httpsPort
|
||||||
user group adminAddr logDir stateDir
|
user group adminAddr logDir stateDir
|
||||||
noUserDir extraDirectories;
|
extraDirectories;
|
||||||
|
noUserDir = !cfg.enableUserDir;
|
||||||
|
|
||||||
subServices =
|
subServices =
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user