0
0
Fork 0
mirror of https://github.com/NixOS/nixpkgs.git synced 2025-07-13 21:50:33 +03:00

nginx: add basic auth support for locations

This commit is contained in:
Graham Christensen 2020-10-20 14:11:21 +00:00
parent 33cf4f0e8e
commit c7bf3828f0
No known key found for this signature in database
GPG key ID: FE918C3A98C1030F
2 changed files with 26 additions and 0 deletions

View file

@ -290,6 +290,7 @@ let
${optionalString (config.return != null) "return ${config.return};"} ${optionalString (config.return != null) "return ${config.return};"}
${config.extraConfig} ${config.extraConfig}
${optionalString (config.proxyPass != null && cfg.recommendedProxySettings) "include ${recommendedProxyConfig};"} ${optionalString (config.proxyPass != null && cfg.recommendedProxySettings) "include ${recommendedProxyConfig};"}
${mkBasicAuth "sublocation" config}
} }
'') (sortProperties (mapAttrsToList (k: v: v // { location = k; }) locations))); '') (sortProperties (mapAttrsToList (k: v: v // { location = k; }) locations)));

View file

@ -9,6 +9,31 @@ with lib;
{ {
options = { options = {
basicAuth = mkOption {
type = types.attrsOf types.str;
default = {};
example = literalExample ''
{
user = "password";
};
'';
description = ''
Basic Auth protection for a vhost.
WARNING: This is implemented to store the password in plain text in the
nix store.
'';
};
basicAuthFile = mkOption {
type = types.nullOr types.path;
default = null;
description = ''
Basic Auth password file for a vhost.
Can be created via: <command>htpasswd -c &lt;filename&gt; &lt;username&gt;</command>
'';
};
proxyPass = mkOption { proxyPass = mkOption {
type = types.nullOr types.str; type = types.nullOr types.str;
default = null; default = null;