Skip to content

Commit 9004cb4

Browse files
authored
nixos/h2o: add simple listen.host setting, add example (#386318)
2 parents 3a8ebeb + 1e3e30d commit 9004cb4

File tree

2 files changed

+44
-6
lines changed

2 files changed

+44
-6
lines changed

nixos/modules/services/web-servers/h2o/default.nix

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,9 @@ let
230230
ssl = (lib.recursiveUpdate tlsRecAttrs value.tls.extraSettings) // {
231231
inherit identity;
232232
};
233+
}
234+
// lib.optionalAttrs (value.host != null) {
235+
host = value.host;
233236
};
234237
};
235238
};
@@ -302,6 +305,22 @@ in
302305
type = settingsFormat.type;
303306
default = { };
304307
description = "Configuration for H2O (see <https://h2o.examp1e.net/configure.html>)";
308+
example =
309+
literalExpression
310+
# nix
311+
''
312+
{
313+
compress = "ON";
314+
ssl-offload = "kernel";
315+
http2-reprioritize-blocking-assets = "ON";
316+
"file.mime.addtypes" = {
317+
"text/x-rst" = {
318+
extensions = [ ".rst" ];
319+
is_compressible = "YES";
320+
};
321+
};
322+
}
323+
'';
305324
};
306325

307326
hosts = mkOption {

nixos/modules/services/web-servers/h2o/vhost-options.nix

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,18 @@ in
3333
"example.org"
3434
];
3535
description = ''
36-
Additional names of virtual hosts served by this virtual host configuration.
36+
Additional names of virtual hosts served by this virtual host
37+
configuration.
38+
'';
39+
};
40+
41+
host = mkOption {
42+
type = types.nullOr types.nonEmptyStr;
43+
default = null;
44+
example = "127.0.0.1";
45+
description = ''
46+
Set the host address for this virtual host. If unset, the default is to
47+
listen on all network interfaces.
3748
'';
3849
};
3950

@@ -70,7 +81,7 @@ in
7081
config.services.h2o.defaultTLSListenPort
7182
'';
7283
description = ''
73-
Override the default TLS port for this virtual host.";
84+
Override the default TLS port for this virtual host.
7485
'';
7586
example = 8443;
7687
};
@@ -105,11 +116,17 @@ in
105116
options = {
106117
key-file = mkOption {
107118
type = types.path;
108-
description = "Path to key file";
119+
description = ''
120+
Path to key file. See
121+
<https://h2o.examp1e.net/configure/base_directives.html#key-file>.
122+
'';
109123
};
110124
certificate-file = mkOption {
111125
type = types.path;
112-
description = "Path to certificate file";
126+
description = ''
127+
Path to certificate file. See
128+
<https://h2o.examp1e.net/configure/base_directives.html#certificate-file>.
129+
'';
113130
};
114131
};
115132
}
@@ -139,7 +156,8 @@ in
139156
type = types.attrs;
140157
default = { };
141158
description = ''
142-
Additional TLS/SSL-related configuration options.
159+
Additional TLS/SSL-related configuration options. See
160+
<https://h2o.examp1e.net/configure/base_directives.html#listen-ssl>.
143161
'';
144162
example =
145163
literalExpression
@@ -205,7 +223,8 @@ in
205223
default = { };
206224
description = ''
207225
Attrset to be transformed into YAML for host config. Note that the HTTP
208-
/ TLS configurations will override these config values.
226+
/ TLS configurations will override these config values. See
227+
<https://h2o.examp1e.net/configure/base_directives.html#hosts>.
209228
'';
210229
};
211230
};

0 commit comments

Comments
 (0)