1{ lib, ...}:
2{ options = {
3 proto = lib.mkOption {
4 type = lib.types.enum [ "h2" "http/1.1" ];
5 default = "http/1.1";
6 description = lib.mdDoc ''
7 This option configures the protocol the backend server expects
8 to use.
9
10 Please see https://nghttp2.org/documentation/nghttpx.1.html#cmdoption-nghttpx-b
11 for more detail.
12 '';
13 };
14
15 tls = lib.mkOption {
16 type = lib.types.bool;
17 default = false;
18 description = lib.mdDoc ''
19 This option determines whether nghttpx will negotiate its
20 connection with a backend server using TLS or not. The burden
21 is on the backend server to provide the TLS certificate!
22
23 Please see https://nghttp2.org/documentation/nghttpx.1.html#cmdoption-nghttpx-b
24 for more detail.
25 '';
26 };
27
28 sni = lib.mkOption {
29 type = lib.types.nullOr lib.types.str;
30 default = null;
31 description = lib.mdDoc ''
32 Override the TLS SNI field value. This value (in nghttpx)
33 defaults to the host value of the backend configuration.
34
35 Please see https://nghttp2.org/documentation/nghttpx.1.html#cmdoption-nghttpx-b
36 for more detail.
37 '';
38 };
39
40 fall = lib.mkOption {
41 type = lib.types.int;
42 default = 0;
43 description = lib.mdDoc ''
44 If nghttpx cannot connect to the backend N times in a row, the
45 backend is assumed to be offline and is excluded from load
46 balancing. If N is 0 the backend is never excluded from load
47 balancing.
48
49 Please see https://nghttp2.org/documentation/nghttpx.1.html#cmdoption-nghttpx-b
50 for more detail.
51 '';
52 };
53
54 rise = lib.mkOption {
55 type = lib.types.int;
56 default = 0;
57 description = lib.mdDoc ''
58 If the backend is excluded from load balancing, nghttpx will
59 periodically attempt to make a connection to the backend. If
60 the connection is successful N times in a row the backend is
61 re-included in load balancing. If N is 0 a backend is never
62 reconsidered for load balancing once it falls.
63
64 Please see https://nghttp2.org/documentation/nghttpx.1.html#cmdoption-nghttpx-b
65 for more detail.
66 '';
67 };
68
69 affinity = lib.mkOption {
70 type = lib.types.enum [ "ip" "none" ];
71 default = "none";
72 description = lib.mdDoc ''
73 If "ip" is given, client IP based session affinity is
74 enabled. If "none" is given, session affinity is disabled.
75
76 Session affinity is enabled (by nghttpx) per-backend
77 pattern. If at least one backend has a non-"none" affinity,
78 then session affinity is enabled for all backend servers
79 sharing the same pattern.
80
81 It is advised to set affinity on all backends explicitly if
82 session affinity is desired. The session affinity may break if
83 one of the backend gets unreachable, or backend settings are
84 reloaded or replaced by API.
85
86 Please see https://nghttp2.org/documentation/nghttpx.1.html#cmdoption-nghttpx-b
87 for more detail.
88 '';
89 };
90
91 dns = lib.mkOption {
92 type = lib.types.bool;
93 default = false;
94 description = lib.mdDoc ''
95 Name resolution of a backends host name is done at start up,
96 or configuration reload. If "dns" is true, name resolution
97 takes place dynamically.
98
99 This is useful if a backends address changes frequently. If
100 "dns" is true, name resolution of a backend's host name at
101 start up, or configuration reload is skipped.
102
103 Please see https://nghttp2.org/documentation/nghttpx.1.html#cmdoption-nghttpx-b
104 for more detail.
105 '';
106 };
107
108 redirect-if-not-tls = lib.mkOption {
109 type = lib.types.bool;
110 default = false;
111 description = lib.mdDoc ''
112 If true, a backend match requires the frontend connection be
113 TLS encrypted. If it is not, nghttpx responds to the request
114 with a 308 status code and https URI the client should use
115 instead in the Location header.
116
117 The port number in the redirect URI is 443 by default and can
118 be changed using 'services.nghttpx.redirect-https-port'
119 option.
120
121 If at least one backend has "redirect-if-not-tls" set to true,
122 this feature is enabled for all backend servers with the same
123 pattern. It is advised to set "redirect-if-no-tls" parameter
124 to all backends explicitly if this feature is desired.
125
126 Please see https://nghttp2.org/documentation/nghttpx.1.html#cmdoption-nghttpx-b
127 for more detail.
128 '';
129 };
130 };
131}