krebs.nginx: don't abuse extraConfig

This commit is contained in:
tv 2016-04-07 20:48:07 +02:00
parent e1a287c78b
commit 7fb1a3e775

View file

@ -117,25 +117,21 @@ let
} }
''; '';
to-server = { server-names, listen, locations, extraConfig, ssl, ... }: to-server = { server-names, listen, locations, extraConfig, ssl, ... }: ''
let server {
_extraConfig = if ssl.enable then server_name ${toString server-names};
extraConfig + '' ${concatMapStringsSep "\n" (x: indent "listen ${x};") listen}
${optionalString ssl.enable (indent ''
listen 443 ssl;
ssl_certificate ${ssl.certificate}; ssl_certificate ${ssl.certificate};
ssl_certificate_key ${ssl.certificate_key}; ssl_certificate_key ${ssl.certificate_key};
${optionalString ssl.prefer_server_ciphers "ssl_prefer_server_ciphers On;"} ${optionalString ssl.prefer_server_ciphers ''
ssl_prefer_server_ciphers On;
''}
ssl_ciphers ${ssl.ciphers}; ssl_ciphers ${ssl.ciphers};
ssl_protocols ${toString ssl.protocols}; ssl_protocols ${toString ssl.protocols};
'' '')}
else ${indent extraConfig}
extraConfig
;
in ''
server {
${concatMapStringsSep "\n" (x: "listen ${x};") (listen ++ optional ssl.enable "443 ssl")}
server_name ${toString server-names};
${indent _extraConfig}
${indent (concatMapStrings to-location locations)} ${indent (concatMapStrings to-location locations)}
} }
''; '';