nixos/h2o: add simple listen.host setting, add example (#386318)

This commit is contained in:
Florian Klink
2025-03-09 11:32:06 +07:00
committed by GitHub
2 changed files with 44 additions and 6 deletions
@@ -230,6 +230,9 @@ let
ssl = (lib.recursiveUpdate tlsRecAttrs value.tls.extraSettings) // {
inherit identity;
};
}
// lib.optionalAttrs (value.host != null) {
host = value.host;
};
};
};
@@ -302,6 +305,22 @@ in
type = settingsFormat.type;
default = { };
description = "Configuration for H2O (see <https://h2o.examp1e.net/configure.html>)";
example =
literalExpression
# nix
''
{
compress = "ON";
ssl-offload = "kernel";
http2-reprioritize-blocking-assets = "ON";
"file.mime.addtypes" = {
"text/x-rst" = {
extensions = [ ".rst" ];
is_compressible = "YES";
};
};
}
'';
};
hosts = mkOption {
@@ -33,7 +33,18 @@ in
"example.org"
];
description = ''
Additional names of virtual hosts served by this virtual host configuration.
Additional names of virtual hosts served by this virtual host
configuration.
'';
};
host = mkOption {
type = types.nullOr types.nonEmptyStr;
default = null;
example = "127.0.0.1";
description = ''
Set the host address for this virtual host. If unset, the default is to
listen on all network interfaces.
'';
};
@@ -70,7 +81,7 @@ in
config.services.h2o.defaultTLSListenPort
'';
description = ''
Override the default TLS port for this virtual host.";
Override the default TLS port for this virtual host.
'';
example = 8443;
};
@@ -105,11 +116,17 @@ in
options = {
key-file = mkOption {
type = types.path;
description = "Path to key file";
description = ''
Path to key file. See
<https://h2o.examp1e.net/configure/base_directives.html#key-file>.
'';
};
certificate-file = mkOption {
type = types.path;
description = "Path to certificate file";
description = ''
Path to certificate file. See
<https://h2o.examp1e.net/configure/base_directives.html#certificate-file>.
'';
};
};
}
@@ -139,7 +156,8 @@ in
type = types.attrs;
default = { };
description = ''
Additional TLS/SSL-related configuration options.
Additional TLS/SSL-related configuration options. See
<https://h2o.examp1e.net/configure/base_directives.html#listen-ssl>.
'';
example =
literalExpression
@@ -205,7 +223,8 @@ in
default = { };
description = ''
Attrset to be transformed into YAML for host config. Note that the HTTP
/ TLS configurations will override these config values.
/ TLS configurations will override these config values. See
<https://h2o.examp1e.net/configure/base_directives.html#hosts>.
'';
};
};