@@ -230,13 +230,13 @@ let
230230
231231 defaultListen =
232232 if vhost.listen != [] then vhost.listen
233− else ((optionals hasSSL (
234− singleton { addr = "0.0.0.0"; port = 443; ssl = true; }
235− ++ optional enableIPv6 { addr = "[::]"; port = 443; ssl = true; }
236− )) ++ optionals (!onlySSL) (
237− singleton { addr = "0.0.0.0"; port = 80; ssl = false; }
238− ++ optional enableIPv6 { addr = "[::]"; port = 80; ssl = false; }
239− ));
233+ else optionals (hasSSL || vhost.rejectSSL) (
234+ singleton { addr = "0.0.0.0"; port = 443; ssl = true; }
235+ ++ optional enableIPv6 { addr = "[::]"; port = 443; ssl = true; }
236+ ) ++ optionals (!onlySSL) (
237+ singleton { addr = "0.0.0.0"; port = 80; ssl = false; }
238+ ++ optional enableIPv6 { addr = "[::]"; port = 80; ssl = false; }
239+ );
240240
241241 hostListen =
242242 if vhost.forceSSL
@@ -303,6 +303,9 @@ let
303303 ${optionalString (hasSSL && vhost.sslTrustedCertificate != null) ''
304304 ssl_trusted_certificate ${vhost.sslTrustedCertificate};
305305 ''}
306+ ${optionalString vhost.rejectSSL ''
307+ ssl_reject_handshake on;
308+ ''}
306309
307310 ${mkBasicAuth vhostName vhost}
308311
@@ -771,20 +774,27 @@ in
771774 }
772775
773776 {
774− assertion = all (conf: with conf;
775− !(addSSL && (onlySSL || enableSSL)) &&
776− !(forceSSL && (onlySSL || enableSSL)) &&
777− !(addSSL && forceSSL)
777+ assertion = all (host: with host;
778+ count id [ addSSL (onlySSL || enableSSL) forceSSL rejectSSL ] <= 1
778779 ) (attrValues virtualHosts);
779780 message = ''
780781 Options services.nginx.service.virtualHosts.<name>.addSSL,
781− services.nginx.virtualHosts.<name>.onlySSL and services.nginx.virtualHosts.<name>.forceSSL
782− are mutually exclusive.
782+ services.nginx.virtualHosts.<name>.onlySSL,
783+ services.nginx.virtualHosts.<name>.forceSSL and
784+ services.nginx.virtualHosts.<name>.rejectSSL are mutually exclusive.
785+ '';
786+ }
787+
788+ {
789+ assertion = any (host: host.rejectSSL) (attrValues virtualHosts) -> versionAtLeast cfg.package.version "1.19.4";
790+ message = ''
791+ services.nginx.virtualHosts.<name>.rejectSSL requires nginx version
792+ 1.19.4 or above; see the documentation for services.nginx.package.
783793 '';
784794 }
785795
786796 {
787− assertion = all (conf: !(conf.enableACME && conf.useACMEHost != null)) (attrValues virtualHosts);
797+ assertion = all (host: !(host.enableACME && host.useACMEHost != null)) (attrValues virtualHosts);
788798 message = ''
789799 Options services.nginx.service.virtualHosts.<name>.enableACME and
790800 services.nginx.virtualHosts.<name>.useACMEHost are mutually exclusive.