diff options
author | Domen Kožar <domen@enlambda.com> | 2017-03-21 15:04:02 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-21 15:04:02 +0100 |
commit | 02129a8788423cb0b3dd4248c1ae342866d0d7ad (patch) | |
tree | 69d258570428f572feb52ec4cfd0e05da01a9672 /nixos/modules/services/web-servers | |
parent | 5bcbffe0dcf5de4978319bd09ad45f954a8d12d8 (diff) | |
parent | a09246948cafb7672ea1e5590688e7eb6a16cef3 (diff) | |
download | nixlib-02129a8788423cb0b3dd4248c1ae342866d0d7ad.tar nixlib-02129a8788423cb0b3dd4248c1ae342866d0d7ad.tar.gz nixlib-02129a8788423cb0b3dd4248c1ae342866d0d7ad.tar.bz2 nixlib-02129a8788423cb0b3dd4248c1ae342866d0d7ad.tar.lz nixlib-02129a8788423cb0b3dd4248c1ae342866d0d7ad.tar.xz nixlib-02129a8788423cb0b3dd4248c1ae342866d0d7ad.tar.zst nixlib-02129a8788423cb0b3dd4248c1ae342866d0d7ad.zip |
Merge pull request #23672 from edanaher/nginx-alias
Nginx alias directive
Diffstat (limited to 'nixos/modules/services/web-servers')
-rw-r--r-- | nixos/modules/services/web-servers/nginx/default.nix | 8 | ||||
-rw-r--r-- | nixos/modules/services/web-servers/nginx/location-options.nix | 9 |
2 files changed, 17 insertions, 0 deletions
diff --git a/nixos/modules/services/web-servers/nginx/default.nix b/nixos/modules/services/web-servers/nginx/default.nix index 4e57b920a7d8..ae14aa28ae34 100644 --- a/nixos/modules/services/web-servers/nginx/default.nix +++ b/nixos/modules/services/web-servers/nginx/default.nix @@ -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" ]; diff --git a/nixos/modules/services/web-servers/nginx/location-options.nix b/nixos/modules/services/web-servers/nginx/location-options.nix index e1885b160664..83ce0f717341 100644 --- a/nixos/modules/services/web-servers/nginx/location-options.nix +++ b/nixos/modules/services/web-servers/nginx/location-options.nix @@ -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 = ""; |