Merge pull request #23672 from edanaher/nginx-alias

Nginx alias directive
This commit is contained in:
Domen Kožar 2017-03-21 15:04:02 +01:00 committed by GitHub
commit 02129a8788
2 changed files with 17 additions and 0 deletions

View File

@ -185,6 +185,7 @@ let
${optionalString (config.index != null) "index ${config.index};"}
${optionalString (config.tryFiles != null) "try_files ${config.tryFiles};"}
${optionalString (config.root != null) "root ${config.root};"}
${optionalString (config.alias != null) "alias ${config.alias};"}
${config.extraConfig}
}
'') locations);
@ -403,6 +404,13 @@ in
config = mkIf cfg.enable {
# TODO: test user supplied config file pases syntax test
assertions = let hostOrAliasIsNull = l: l.root == null || l.alias == null; in [
{
assertion = all (host: all hostOrAliasIsNull (attrValues host.locations)) (attrValues virtualHosts);
message = "Only one of nginx root or alias can be specified on a location.";
}
];
systemd.services.nginx = {
description = "Nginx Web Server";
after = [ "network.target" ];

View File

@ -45,6 +45,15 @@ with lib;
'';
};
alias = mkOption {
type = types.nullOr types.path;
default = null;
example = "/your/alias/directory";
description = ''
Alias directory for requests.
'';
};
extraConfig = mkOption {
type = types.lines;
default = "";