Merge pull request #134008 from aanderse/httpd

nixos/httpd: add virtualHosts.<name>.listenAddresses option
This commit is contained in:
Robert Hensing 2021-08-21 09:30:35 +02:00 committed by GitHub
commit a1cdf552dc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 7 deletions

View file

@ -36,11 +36,12 @@ let
dependentCertNames = unique (map (hostOpts: hostOpts.certName) acmeEnabledVhosts);
mkListenInfo = hostOpts:
if hostOpts.listen != [] then hostOpts.listen
else (
optional (hostOpts.onlySSL || hostOpts.addSSL || hostOpts.forceSSL) { ip = "*"; port = 443; ssl = true; } ++
optional (!hostOpts.onlySSL) { ip = "*"; port = 80; ssl = false; }
);
if hostOpts.listen != [] then
hostOpts.listen
else
optionals (hostOpts.onlySSL || hostOpts.addSSL || hostOpts.forceSSL) (map (addr: { ip = addr; port = 443; ssl = true; }) hostOpts.listenAddresses) ++
optionals (!hostOpts.onlySSL) (map (addr: { ip = addr; port = 80; ssl = false; }) hostOpts.listenAddresses)
;
listenInfo = unique (concatMap mkListenInfo vhosts);

View file

@ -47,12 +47,29 @@ in
];
description = ''
Listen addresses and ports for this virtual host.
<note><para>
<note>
<para>
This option overrides <literal>addSSL</literal>, <literal>forceSSL</literal> and <literal>onlySSL</literal>.
</para></note>
</para>
<para>
If you only want to set the addresses manually and not the ports, take a look at <literal>listenAddresses</literal>.
</para>
</note>
'';
};
listenAddresses = mkOption {
type = with types; nonEmptyListOf str;
description = ''
Listen addresses for this virtual host.
Compared to <literal>listen</literal> this only sets the addreses
and the ports are chosen automatically.
'';
default = [ "*" ];
example = [ "127.0.0.1" ];
};
enableSSL = mkOption {
type = types.bool;
visible = false;