@@ -218,7 +218,10 @@ let
218218 ssl_certificate_key ${vhost.sslCertificateKey};
219219 ''}
220220
221− ${optionalString (vhost.basicAuth != {}) (mkBasicAuth vhostName vhost.basicAuth)}
221+ ${optionalString (vhost.basicAuthFile != null || vhost.basicAuth != {}) ''
222+ auth_basic secured;
223+ auth_basic_user_file ${if vhost.basicAuthFile != null then vhost.basicAuthFile else mkHtpasswd vhostName vhost.basicAuth};
224+ ''}
222225
223226 ${mkLocations vhost.locations}
224227
@@ -248,16 +251,11 @@ let
248251 ${optionalString (config.proxyPass != null && cfg.recommendedProxySettings) "include ${recommendedProxyConfig};"}
249252 }
250253 '') locations);
251− mkBasicAuth = vhostName: authDef: let
252− htpasswdFile = pkgs.writeText "${vhostName}.htpasswd" (
253− concatStringsSep "\n" (mapAttrsToList (user: password: ''
254− ${user}:{PLAIN}${password}
255− '') authDef)
256− );
257− in ''
258− auth_basic secured;
259− auth_basic_user_file ${htpasswdFile};
260− '';
254+ mkHtpasswd = vhostName: authDef: pkgs.writeText "${vhostName}.htpasswd" (
255+ concatStringsSep "\n" (mapAttrsToList (user: password: ''
256+ ${user}:{PLAIN}${password}
257+ '') authDef)
258+ );
261259in
262260
263261{