Imported Upstream version 1.41.0
[platform/upstream/nghttp2.git] / doc / nghttpx.1
1 .\" Man page generated from reStructuredText.
2 .
3 .TH "NGHTTPX" "1" "Jun 02, 2020" "1.41.0" "nghttp2"
4 .SH NAME
5 nghttpx \- HTTP/2 proxy
6 .
7 .nr rst2man-indent-level 0
8 .
9 .de1 rstReportMargin
10 \\$1 \\n[an-margin]
11 level \\n[rst2man-indent-level]
12 level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
13 -
14 \\n[rst2man-indent0]
15 \\n[rst2man-indent1]
16 \\n[rst2man-indent2]
17 ..
18 .de1 INDENT
19 .\" .rstReportMargin pre:
20 . RS \\$1
21 . nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin]
22 . nr rst2man-indent-level +1
23 .\" .rstReportMargin post:
24 ..
25 .de UNINDENT
26 . RE
27 .\" indent \\n[an-margin]
28 .\" old: \\n[rst2man-indent\\n[rst2man-indent-level]]
29 .nr rst2man-indent-level -1
30 .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
31 .in \\n[rst2man-indent\\n[rst2man-indent-level]]u
32 ..
33 .SH SYNOPSIS
34 .sp
35 \fBnghttpx\fP [OPTIONS]... [<PRIVATE_KEY> <CERT>]
36 .SH DESCRIPTION
37 .sp
38 A reverse proxy for HTTP/2, and HTTP/1.
39 .INDENT 0.0
40 .TP
41 .B <PRIVATE_KEY>
42 Set  path  to  server\(aqs private  key.   Required  unless
43 "no\-tls" parameter is used in \fI\%\-\-frontend\fP option.
44 .UNINDENT
45 .INDENT 0.0
46 .TP
47 .B <CERT>
48 Set  path  to  server\(aqs  certificate.   Required  unless
49 "no\-tls"  parameter is  used in  \fI\%\-\-frontend\fP option.   To
50 make OCSP stapling work, this must be an absolute path.
51 .UNINDENT
52 .SH OPTIONS
53 .sp
54 The options are categorized into several groups.
55 .SS Connections
56 .INDENT 0.0
57 .TP
58 .B \-b, \-\-backend=(<HOST>,<PORT>|unix:<PATH>)[;[<PATTERN>[:...]][[;<PARAM>]...]
59 Set  backend  host  and   port.   The  multiple  backend
60 addresses are  accepted by repeating this  option.  UNIX
61 domain socket  can be  specified by prefixing  path name
62 with "unix:" (e.g., unix:/var/run/backend.sock).
63 .sp
64 Optionally, if <PATTERN>s are given, the backend address
65 is  only  used  if  request matches  the  pattern.   The
66 pattern  matching is  closely  designed  to ServeMux  in
67 net/http package of  Go programming language.  <PATTERN>
68 consists of  path, host +  path or just host.   The path
69 must start  with "\fI/\fP".  If  it ends with "\fI/\fP",  it matches
70 all  request path  in  its subtree.   To  deal with  the
71 request  to the  directory without  trailing slash,  the
72 path which ends  with "\fI/\fP" also matches  the request path
73 which  only  lacks  trailing  \(aq\fI/\fP\(aq  (e.g.,  path  "\fI/foo/\fP"
74 matches request path  "\fI/foo\fP").  If it does  not end with
75 "\fI/\fP", it  performs exact match against  the request path.
76 If  host  is given,  it  performs  a match  against  the
77 request host.   For a  request received on  the frontend
78 listener with  "sni\-fwd" parameter enabled, SNI  host is
79 used instead of a request host.  If host alone is given,
80 "\fI/\fP" is  appended to it,  so that it matches  all request
81 paths  under the  host  (e.g., specifying  "nghttp2.org"
82 equals  to "nghttp2.org/").   CONNECT method  is treated
83 specially.  It  does not have  path, and we  don\(aqt allow
84 empty path.  To workaround  this, we assume that CONNECT
85 method has "\fI/\fP" as path.
86 .sp
87 Patterns with  host take  precedence over  patterns with
88 just path.   Then, longer patterns take  precedence over
89 shorter ones.
90 .sp
91 Host  can  include "*"  in  the  left most  position  to
92 indicate  wildcard match  (only suffix  match is  done).
93 The "*" must match at least one character.  For example,
94 host    pattern    "*.nghttp2.org"    matches    against
95 "www.nghttp2.org"  and  "git.ngttp2.org", but  does  not
96 match  against  "nghttp2.org".   The exact  hosts  match
97 takes precedence over the wildcard hosts match.
98 .sp
99 If path  part ends with  "*", it is treated  as wildcard
100 path.  The  wildcard path  behaves differently  from the
101 normal path.  For normal path,  match is made around the
102 boundary of path component  separator,"\fI/\fP".  On the other
103 hand, the wildcard  path does not take  into account the
104 path component  separator.  All paths which  include the
105 wildcard  path  without  last  "*" as  prefix,  and  are
106 strictly longer than wildcard  path without last "*" are
107 matched.  "*"  must match  at least one  character.  For
108 example,  the   pattern  "\fI/foo*\fP"  matches   "\fI/foo/\fP"  and
109 "\fI/foobar\fP".  But it does not match "\fI/foo\fP", or "\fI/fo\fP".
110 .sp
111 If <PATTERN> is omitted or  empty string, "\fI/\fP" is used as
112 pattern,  which  matches  all request  paths  (catch\-all
113 pattern).  The catch\-all backend must be given.
114 .sp
115 When doing  a match, nghttpx made  some normalization to
116 pattern, request host and path.  For host part, they are
117 converted to lower case.  For path part, percent\-encoded
118 unreserved characters  defined in RFC 3986  are decoded,
119 and any  dot\-segments (".."  and ".")   are resolved and
120 removed.
121 .sp
122 For   example,   \fI\%\-b\fP\(aq127.0.0.1,8080;nghttp2.org/httpbin/\(aq
123 matches the  request host "nghttp2.org" and  the request
124 path "\fI/httpbin/get\fP", but does not match the request host
125 "nghttp2.org" and the request path "\fI/index.html\fP".
126 .sp
127 The  multiple <PATTERN>s  can  be specified,  delimiting
128 them            by           ":".             Specifying
129 \fI\%\-b\fP\(aq127.0.0.1,8080;nghttp2.org:www.nghttp2.org\(aq  has  the
130 same  effect  to specify  \fI\%\-b\fP\(aq127.0.0.1,8080;nghttp2.org\(aq
131 and \fI\%\-b\fP\(aq127.0.0.1,8080;www.nghttp2.org\(aq.
132 .sp
133 The backend addresses sharing same <PATTERN> are grouped
134 together forming  load balancing  group.
135 .sp
136 Several parameters <PARAM> are accepted after <PATTERN>.
137 The  parameters are  delimited  by  ";".  The  available
138 parameters       are:      "proto=<PROTO>",       "tls",
139 "sni=<SNI_HOST>",         "fall=<N>",        "rise=<N>",
140 "affinity=<METHOD>",    "dns",    "redirect\-if\-not\-tls",
141 "upgrade\-scheme",                        "mruby=<PATH>",
142 "read\-timeout=<DURATION>",   "write\-timeout=<DURATION>",
143 "group=<GROUP>",  "group\-weight=<N>", and  "weight=<N>".
144 The  parameter  consists   of  keyword,  and  optionally
145 followed by  "=" and value.  For  example, the parameter
146 "proto=h2"  consists of  the keyword  "proto" and  value
147 "h2".  The parameter "tls" consists of the keyword "tls"
148 without value.  Each parameter is described as follows.
149 .sp
150 The backend application protocol  can be specified using
151 optional  "proto"   parameter,  and   in  the   form  of
152 "proto=<PROTO>".  <PROTO> should be one of the following
153 list  without  quotes:  "h2", "http/1.1".   The  default
154 value of <PROTO> is  "http/1.1".  Note that usually "h2"
155 refers to HTTP/2  over TLS.  But in this  option, it may
156 mean HTTP/2  over cleartext TCP unless  "tls" keyword is
157 used (see below).
158 .sp
159 TLS  can   be  enabled  by  specifying   optional  "tls"
160 parameter.  TLS is not enabled by default.
161 .sp
162 With "sni=<SNI_HOST>" parameter, it can override the TLS
163 SNI  field  value  with  given  <SNI_HOST>.   This  will
164 default to the backend <HOST> name
165 .sp
166 The  feature  to detect  whether  backend  is online  or
167 offline can be enabled  using optional "fall" and "rise"
168 parameters.   Using  "fall=<N>"  parameter,  if  nghttpx
169 cannot connect  to a  this backend <N>  times in  a row,
170 this  backend  is  assumed  to be  offline,  and  it  is
171 excluded from load balancing.  If <N> is 0, this backend
172 never  be excluded  from load  balancing whatever  times
173 nghttpx cannot connect  to it, and this  is the default.
174 There is  also "rise=<N>" parameter.  After  backend was
175 excluded from load balancing group, nghttpx periodically
176 attempts to make a connection to the failed backend, and
177 if the  connection is made  successfully <N> times  in a
178 row, the backend is assumed to  be online, and it is now
179 eligible  for load  balancing target.   If <N>  is 0,  a
180 backend  is permanently  offline, once  it goes  in that
181 state, and this is the default behaviour.
182 .sp
183 The     session     affinity    is     enabled     using
184 "affinity=<METHOD>"  parameter.   If  "ip" is  given  in
185 <METHOD>, client  IP based session affinity  is enabled.
186 If "cookie"  is given in <METHOD>,  cookie based session
187 affinity is  enabled.  If  "none" is given  in <METHOD>,
188 session affinity  is disabled, and this  is the default.
189 The session  affinity is  enabled per <PATTERN>.   If at
190 least  one backend  has  "affinity"  parameter, and  its
191 <METHOD> is not "none",  session affinity is enabled for
192 all backend  servers sharing the same  <PATTERN>.  It is
193 advised  to  set  "affinity" parameter  to  all  backend
194 explicitly if session affinity  is desired.  The session
195 affinity  may   break  if   one  of  the   backend  gets
196 unreachable,  or   backend  settings  are   reloaded  or
197 replaced by API.
198 .sp
199 If   "affinity=cookie"    is   used,    the   additional
200 configuration                is                required.
201 "affinity\-cookie\-name=<NAME>" must be  used to specify a
202 name     of     cookie      to     use.      Optionally,
203 "affinity\-cookie\-path=<PATH>" can  be used to  specify a
204 path   which   cookie    is   applied.    The   optional
205 "affinity\-cookie\-secure=<SECURE>"  controls  the  Secure
206 attribute of a cookie.  The default value is "auto", and
207 the Secure attribute is  determined by a request scheme.
208 If a request scheme is "https", then Secure attribute is
209 set.  Otherwise, it  is not set.  If  <SECURE> is "yes",
210 the  Secure attribute  is  always set.   If <SECURE>  is
211 "no", the Secure attribute is always omitted.
212 .sp
213 By default, name resolution of backend host name is done
214 at  start  up,  or reloading  configuration.   If  "dns"
215 parameter   is  given,   name  resolution   takes  place
216 dynamically.  This is useful  if backend address changes
217 frequently.   If  "dns"  is given,  name  resolution  of
218 backend   host   name   at  start   up,   or   reloading
219 configuration is skipped.
220 .sp
221 If "redirect\-if\-not\-tls" parameter  is used, the matched
222 backend  requires   that  frontend  connection   is  TLS
223 encrypted.  If it isn\(aqt, nghttpx responds to the request
224 with 308  status code, and  https URI the  client should
225 use instead  is included in Location  header field.  The
226 port number in  redirect URI is 443 by  default, and can
227 be  changed using  \fI\%\-\-redirect\-https\-port\fP option.   If at
228 least one  backend has  "redirect\-if\-not\-tls" parameter,
229 this feature is enabled  for all backend servers sharing
230 the   same   <PATTERN>.    It    is   advised   to   set
231 "redirect\-if\-no\-tls"    parameter   to    all   backends
232 explicitly if this feature is desired.
233 .sp
234 If "upgrade\-scheme"  parameter is used along  with "tls"
235 parameter, HTTP/2 :scheme pseudo header field is changed
236 to "https" from "http" when forwarding a request to this
237 particular backend.  This is  a workaround for a backend
238 server  which  requires  "https" :scheme  pseudo  header
239 field on TLS encrypted connection.
240 .sp
241 "mruby=<PATH>"  parameter  specifies  a  path  to  mruby
242 script  file  which  is  invoked when  this  pattern  is
243 matched.  All backends which share the same pattern must
244 have the same mruby path.
245 .sp
246 "read\-timeout=<DURATION>" and "write\-timeout=<DURATION>"
247 parameters  specify the  read and  write timeout  of the
248 backend connection  when this  pattern is  matched.  All
249 backends which share the same pattern must have the same
250 timeouts.  If these timeouts  are entirely omitted for a
251 pattern,            \fI\%\-\-backend\-read\-timeout\fP           and
252 \fI\%\-\-backend\-write\-timeout\fP are used.
253 .sp
254 "group=<GROUP>"  parameter specifies  the name  of group
255 this backend address belongs to.  By default, it belongs
256 to  the unnamed  default group.   The name  of group  is
257 unique   per   pattern.   "group\-weight=<N>"   parameter
258 specifies the  weight of  the group.  The  higher weight
259 gets  more frequently  selected  by  the load  balancing
260 algorithm.  <N> must be  [1, 256] inclusive.  The weight
261 8 has 4 times more weight  than 2.  <N> must be the same
262 for  all addresses  which  share the  same <GROUP>.   If
263 "group\-weight" is  omitted in an address,  but the other
264 address  which  belongs  to  the  same  group  specifies
265 "group\-weight",   its    weight   is   used.     If   no
266 "group\-weight"  is  specified  for  all  addresses,  the
267 weight of a group becomes 1.  "group" and "group\-weight"
268 are ignored if session affinity is enabled.
269 .sp
270 "weight=<N>"  parameter  specifies  the  weight  of  the
271 backend  address  inside  a  group  which  this  address
272 belongs  to.  The  higher  weight  gets more  frequently
273 selected by  the load balancing algorithm.   <N> must be
274 [1,  256] inclusive.   The  weight 8  has  4 times  more
275 weight  than weight  2.  If  this parameter  is omitted,
276 weight  becomes  1.   "weight"  is  ignored  if  session
277 affinity is enabled.
278 .sp
279 Since ";" and ":" are  used as delimiter, <PATTERN> must
280 not  contain these  characters.  Since  ";" has  special
281 meaning in shell, the option value must be quoted.
282 .sp
283 Default: \fB127.0.0.1,80\fP
284 .UNINDENT
285 .INDENT 0.0
286 .TP
287 .B \-f, \-\-frontend=(<HOST>,<PORT>|unix:<PATH>)[[;<PARAM>]...]
288 Set  frontend  host and  port.   If  <HOST> is  \(aq*\(aq,  it
289 assumes  all addresses  including  both  IPv4 and  IPv6.
290 UNIX domain  socket can  be specified by  prefixing path
291 name  with  "unix:" (e.g.,  unix:/var/run/nghttpx.sock).
292 This  option can  be used  multiple times  to listen  to
293 multiple addresses.
294 .sp
295 This option  can take  0 or  more parameters,  which are
296 described  below.   Note   that  "api"  and  "healthmon"
297 parameters are mutually exclusive.
298 .sp
299 Optionally, TLS  can be disabled by  specifying "no\-tls"
300 parameter.  TLS is enabled by default.
301 .sp
302 If "sni\-fwd" parameter is  used, when performing a match
303 to select a backend server,  SNI host name received from
304 the client  is used  instead of  the request  host.  See
305 \fI\%\-\-backend\fP option about the pattern match.
306 .sp
307 To  make this  frontend as  API endpoint,  specify "api"
308 parameter.   This   is  disabled  by  default.    It  is
309 important  to  limit the  access  to  the API  frontend.
310 Otherwise, someone  may change  the backend  server, and
311 break your services,  or expose confidential information
312 to the outside the world.
313 .sp
314 To  make  this  frontend  as  health  monitor  endpoint,
315 specify  "healthmon"  parameter.   This is  disabled  by
316 default.  Any  requests which come through  this address
317 are replied with 200 HTTP status, without no body.
318 .sp
319 To accept  PROXY protocol  version 1  and 2  on frontend
320 connection,  specify  "proxyproto" parameter.   This  is
321 disabled by default.
322 .sp
323 Default: \fB*,3000\fP
324 .UNINDENT
325 .INDENT 0.0
326 .TP
327 .B \-\-backlog=<N>
328 Set listen backlog size.
329 .sp
330 Default: \fB65536\fP
331 .UNINDENT
332 .INDENT 0.0
333 .TP
334 .B \-\-backend\-address\-family=(auto|IPv4|IPv6)
335 Specify  address  family  of  backend  connections.   If
336 "auto" is given, both IPv4  and IPv6 are considered.  If
337 "IPv4" is  given, only  IPv4 address is  considered.  If
338 "IPv6" is given, only IPv6 address is considered.
339 .sp
340 Default: \fBauto\fP
341 .UNINDENT
342 .INDENT 0.0
343 .TP
344 .B \-\-backend\-http\-proxy\-uri=<URI>
345 Specify      proxy       URI      in       the      form
346 \fI\%http:/\fP/[<USER>:<PASS>@]<PROXY>:<PORT>.    If   a   proxy
347 requires  authentication,  specify  <USER>  and  <PASS>.
348 Note that  they must be properly  percent\-encoded.  This
349 proxy  is used  when the  backend connection  is HTTP/2.
350 First,  make  a CONNECT  request  to  the proxy  and  it
351 connects  to the  backend  on behalf  of nghttpx.   This
352 forms  tunnel.   After  that, nghttpx  performs  SSL/TLS
353 handshake with  the downstream through the  tunnel.  The
354 timeouts when connecting and  making CONNECT request can
355 be     specified    by     \fI\%\-\-backend\-read\-timeout\fP    and
356 \fI\%\-\-backend\-write\-timeout\fP options.
357 .UNINDENT
358 .SS Performance
359 .INDENT 0.0
360 .TP
361 .B \-n, \-\-workers=<N>
362 Set the number of worker threads.
363 .sp
364 Default: \fB1\fP
365 .UNINDENT
366 .INDENT 0.0
367 .TP
368 .B \-\-single\-thread
369 Run everything in one  thread inside the worker process.
370 This   feature   is   provided  for   better   debugging
371 experience,  or  for  the platforms  which  lack  thread
372 support.   If  threading  is disabled,  this  option  is
373 always enabled.
374 .UNINDENT
375 .INDENT 0.0
376 .TP
377 .B \-\-read\-rate=<SIZE>
378 Set maximum  average read  rate on  frontend connection.
379 Setting 0 to this option means read rate is unlimited.
380 .sp
381 Default: \fB0\fP
382 .UNINDENT
383 .INDENT 0.0
384 .TP
385 .B \-\-read\-burst=<SIZE>
386 Set  maximum read  burst  size  on frontend  connection.
387 Setting  0  to this  option  means  read burst  size  is
388 unlimited.
389 .sp
390 Default: \fB0\fP
391 .UNINDENT
392 .INDENT 0.0
393 .TP
394 .B \-\-write\-rate=<SIZE>
395 Set maximum  average write rate on  frontend connection.
396 Setting 0 to this option means write rate is unlimited.
397 .sp
398 Default: \fB0\fP
399 .UNINDENT
400 .INDENT 0.0
401 .TP
402 .B \-\-write\-burst=<SIZE>
403 Set  maximum write  burst size  on frontend  connection.
404 Setting  0 to  this  option means  write  burst size  is
405 unlimited.
406 .sp
407 Default: \fB0\fP
408 .UNINDENT
409 .INDENT 0.0
410 .TP
411 .B \-\-worker\-read\-rate=<SIZE>
412 Set maximum average read rate on frontend connection per
413 worker.  Setting  0 to  this option  means read  rate is
414 unlimited.  Not implemented yet.
415 .sp
416 Default: \fB0\fP
417 .UNINDENT
418 .INDENT 0.0
419 .TP
420 .B \-\-worker\-read\-burst=<SIZE>
421 Set maximum  read burst size on  frontend connection per
422 worker.  Setting 0 to this  option means read burst size
423 is unlimited.  Not implemented yet.
424 .sp
425 Default: \fB0\fP
426 .UNINDENT
427 .INDENT 0.0
428 .TP
429 .B \-\-worker\-write\-rate=<SIZE>
430 Set maximum  average write  rate on  frontend connection
431 per worker.  Setting  0 to this option  means write rate
432 is unlimited.  Not implemented yet.
433 .sp
434 Default: \fB0\fP
435 .UNINDENT
436 .INDENT 0.0
437 .TP
438 .B \-\-worker\-write\-burst=<SIZE>
439 Set maximum write burst  size on frontend connection per
440 worker.  Setting 0 to this option means write burst size
441 is unlimited.  Not implemented yet.
442 .sp
443 Default: \fB0\fP
444 .UNINDENT
445 .INDENT 0.0
446 .TP
447 .B \-\-worker\-frontend\-connections=<N>
448 Set maximum number  of simultaneous connections frontend
449 accepts.  Setting 0 means unlimited.
450 .sp
451 Default: \fB0\fP
452 .UNINDENT
453 .INDENT 0.0
454 .TP
455 .B \-\-backend\-connections\-per\-host=<N>
456 Set  maximum number  of  backend concurrent  connections
457 (and/or  streams in  case  of HTTP/2)  per origin  host.
458 This option  is meaningful when \fI\%\-\-http2\-proxy\fP  option is
459 used.   The  origin  host  is  determined  by  authority
460 portion of  request URI (or :authority  header field for
461 HTTP/2).   To  limit  the   number  of  connections  per
462 frontend        for       default        mode,       use
463 \fI\%\-\-backend\-connections\-per\-frontend\fP\&.
464 .sp
465 Default: \fB8\fP
466 .UNINDENT
467 .INDENT 0.0
468 .TP
469 .B \-\-backend\-connections\-per\-frontend=<N>
470 Set  maximum number  of  backend concurrent  connections
471 (and/or streams  in case of HTTP/2)  per frontend.  This
472 option  is   only  used  for  default   mode.   0  means
473 unlimited.  To limit the  number of connections per host
474 with          \fI\%\-\-http2\-proxy\fP         option,          use
475 \fI\%\-\-backend\-connections\-per\-host\fP\&.
476 .sp
477 Default: \fB0\fP
478 .UNINDENT
479 .INDENT 0.0
480 .TP
481 .B \-\-rlimit\-nofile=<N>
482 Set maximum number of open files (RLIMIT_NOFILE) to <N>.
483 If 0 is given, nghttpx does not set the limit.
484 .sp
485 Default: \fB0\fP
486 .UNINDENT
487 .INDENT 0.0
488 .TP
489 .B \-\-backend\-request\-buffer=<SIZE>
490 Set buffer size used to store backend request.
491 .sp
492 Default: \fB16K\fP
493 .UNINDENT
494 .INDENT 0.0
495 .TP
496 .B \-\-backend\-response\-buffer=<SIZE>
497 Set buffer size used to store backend response.
498 .sp
499 Default: \fB128K\fP
500 .UNINDENT
501 .INDENT 0.0
502 .TP
503 .B \-\-fastopen=<N>
504 Enables  "TCP Fast  Open" for  the listening  socket and
505 limits the  maximum length for the  queue of connections
506 that have not yet completed the three\-way handshake.  If
507 value is 0 then fast open is disabled.
508 .sp
509 Default: \fB0\fP
510 .UNINDENT
511 .INDENT 0.0
512 .TP
513 .B \-\-no\-kqueue
514 Don\(aqt use  kqueue.  This  option is only  applicable for
515 the platforms  which have kqueue.  For  other platforms,
516 this option will be simply ignored.
517 .UNINDENT
518 .SS Timeout
519 .INDENT 0.0
520 .TP
521 .B \-\-frontend\-http2\-read\-timeout=<DURATION>
522 Specify read timeout for HTTP/2 frontend connection.
523 .sp
524 Default: \fB3m\fP
525 .UNINDENT
526 .INDENT 0.0
527 .TP
528 .B \-\-frontend\-read\-timeout=<DURATION>
529 Specify read timeout for HTTP/1.1 frontend connection.
530 .sp
531 Default: \fB1m\fP
532 .UNINDENT
533 .INDENT 0.0
534 .TP
535 .B \-\-frontend\-write\-timeout=<DURATION>
536 Specify write timeout for all frontend connections.
537 .sp
538 Default: \fB30s\fP
539 .UNINDENT
540 .INDENT 0.0
541 .TP
542 .B \-\-frontend\-keep\-alive\-timeout=<DURATION>
543 Specify   keep\-alive   timeout   for   frontend   HTTP/1
544 connection.
545 .sp
546 Default: \fB1m\fP
547 .UNINDENT
548 .INDENT 0.0
549 .TP
550 .B \-\-stream\-read\-timeout=<DURATION>
551 Specify  read timeout  for HTTP/2  streams.  0  means no
552 timeout.
553 .sp
554 Default: \fB0\fP
555 .UNINDENT
556 .INDENT 0.0
557 .TP
558 .B \-\-stream\-write\-timeout=<DURATION>
559 Specify write  timeout for  HTTP/2 streams.  0  means no
560 timeout.
561 .sp
562 Default: \fB1m\fP
563 .UNINDENT
564 .INDENT 0.0
565 .TP
566 .B \-\-backend\-read\-timeout=<DURATION>
567 Specify read timeout for backend connection.
568 .sp
569 Default: \fB1m\fP
570 .UNINDENT
571 .INDENT 0.0
572 .TP
573 .B \-\-backend\-write\-timeout=<DURATION>
574 Specify write timeout for backend connection.
575 .sp
576 Default: \fB30s\fP
577 .UNINDENT
578 .INDENT 0.0
579 .TP
580 .B \-\-backend\-connect\-timeout=<DURATION>
581 Specify  timeout before  establishing TCP  connection to
582 backend.
583 .sp
584 Default: \fB30s\fP
585 .UNINDENT
586 .INDENT 0.0
587 .TP
588 .B \-\-backend\-keep\-alive\-timeout=<DURATION>
589 Specify   keep\-alive   timeout    for   backend   HTTP/1
590 connection.
591 .sp
592 Default: \fB2s\fP
593 .UNINDENT
594 .INDENT 0.0
595 .TP
596 .B \-\-listener\-disable\-timeout=<DURATION>
597 After accepting  connection failed,  connection listener
598 is disabled  for a given  amount of time.   Specifying 0
599 disables this feature.
600 .sp
601 Default: \fB30s\fP
602 .UNINDENT
603 .INDENT 0.0
604 .TP
605 .B \-\-frontend\-http2\-setting\-timeout=<DURATION>
606 Specify  timeout before  SETTINGS ACK  is received  from
607 client.
608 .sp
609 Default: \fB10s\fP
610 .UNINDENT
611 .INDENT 0.0
612 .TP
613 .B \-\-backend\-http2\-settings\-timeout=<DURATION>
614 Specify  timeout before  SETTINGS ACK  is received  from
615 backend server.
616 .sp
617 Default: \fB10s\fP
618 .UNINDENT
619 .INDENT 0.0
620 .TP
621 .B \-\-backend\-max\-backoff=<DURATION>
622 Specify  maximum backoff  interval.  This  is used  when
623 doing health  check against offline backend  (see "fail"
624 parameter  in \fI\%\-\-backend\fP  option).   It is  also used  to
625 limit  the  maximum   interval  to  temporarily  disable
626 backend  when nghttpx  failed to  connect to  it.  These
627 intervals are calculated  using exponential backoff, and
628 consecutive failed attempts increase the interval.  This
629 option caps its maximum value.
630 .sp
631 Default: \fB2m\fP
632 .UNINDENT
633 .SS SSL/TLS
634 .INDENT 0.0
635 .TP
636 .B \-\-ciphers=<SUITE>
637 Set allowed  cipher list  for frontend  connection.  The
638 format of the string is described in OpenSSL ciphers(1).
639 This option  sets cipher suites for  TLSv1.2 or earlier.
640 Use \fI\%\-\-tls13\-ciphers\fP for TLSv1.3.
641 .sp
642 Default: \fBECDHE\-ECDSA\-AES256\-GCM\-SHA384:ECDHE\-RSA\-AES256\-GCM\-SHA384:ECDHE\-ECDSA\-CHACHA20\-POLY1305:ECDHE\-RSA\-CHACHA20\-POLY1305:ECDHE\-ECDSA\-AES128\-GCM\-SHA256:ECDHE\-RSA\-AES128\-GCM\-SHA256:ECDHE\-ECDSA\-AES256\-SHA384:ECDHE\-RSA\-AES256\-SHA384:ECDHE\-ECDSA\-AES128\-SHA256:ECDHE\-RSA\-AES128\-SHA256\fP
643 .UNINDENT
644 .INDENT 0.0
645 .TP
646 .B \-\-tls13\-ciphers=<SUITE>
647 Set allowed  cipher list  for frontend  connection.  The
648 format of the string is described in OpenSSL ciphers(1).
649 This  option  sets  cipher   suites  for  TLSv1.3.   Use
650 \fI\%\-\-ciphers\fP for TLSv1.2 or earlier.
651 .sp
652 Default: \fBTLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_128_GCM_SHA256\fP
653 .UNINDENT
654 .INDENT 0.0
655 .TP
656 .B \-\-client\-ciphers=<SUITE>
657 Set  allowed cipher  list for  backend connection.   The
658 format of the string is described in OpenSSL ciphers(1).
659 This option  sets cipher suites for  TLSv1.2 or earlier.
660 Use \fI\%\-\-tls13\-client\-ciphers\fP for TLSv1.3.
661 .sp
662 Default: \fBECDHE\-ECDSA\-AES256\-GCM\-SHA384:ECDHE\-RSA\-AES256\-GCM\-SHA384:ECDHE\-ECDSA\-CHACHA20\-POLY1305:ECDHE\-RSA\-CHACHA20\-POLY1305:ECDHE\-ECDSA\-AES128\-GCM\-SHA256:ECDHE\-RSA\-AES128\-GCM\-SHA256:ECDHE\-ECDSA\-AES256\-SHA384:ECDHE\-RSA\-AES256\-SHA384:ECDHE\-ECDSA\-AES128\-SHA256:ECDHE\-RSA\-AES128\-SHA256\fP
663 .UNINDENT
664 .INDENT 0.0
665 .TP
666 .B \-\-tls13\-client\-ciphers=<SUITE>
667 Set  allowed cipher  list for  backend connection.   The
668 format of the string is described in OpenSSL ciphers(1).
669 This  option  sets  cipher   suites  for  TLSv1.3.   Use
670 \fI\%\-\-tls13\-client\-ciphers\fP for TLSv1.2 or earlier.
671 .sp
672 Default: \fBTLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_128_GCM_SHA256\fP
673 .UNINDENT
674 .INDENT 0.0
675 .TP
676 .B \-\-ecdh\-curves=<LIST>
677 Set  supported  curve  list  for  frontend  connections.
678 <LIST> is a  colon separated list of curve  NID or names
679 in the preference order.  The supported curves depend on
680 the  linked  OpenSSL  library.  This  function  requires
681 OpenSSL >= 1.0.2.
682 .sp
683 Default: \fBX25519:P\-256:P\-384:P\-521\fP
684 .UNINDENT
685 .INDENT 0.0
686 .TP
687 .B \-k, \-\-insecure
688 Don\(aqt  verify backend  server\(aqs  certificate  if TLS  is
689 enabled for backend connections.
690 .UNINDENT
691 .INDENT 0.0
692 .TP
693 .B \-\-cacert=<PATH>
694 Set path to trusted CA  certificate file.  It is used in
695 backend  TLS connections  to verify  peer\(aqs certificate.
696 It is also used to  verify OCSP response from the script
697 set by \fI\%\-\-fetch\-ocsp\-response\-file\fP\&.  The  file must be in
698 PEM format.   It can contain multiple  certificates.  If
699 the  linked OpenSSL  is configured  to load  system wide
700 certificates, they  are loaded at startup  regardless of
701 this option.
702 .UNINDENT
703 .INDENT 0.0
704 .TP
705 .B \-\-private\-key\-passwd\-file=<PATH>
706 Path  to file  that contains  password for  the server\(aqs
707 private key.   If none is  given and the private  key is
708 password protected it\(aqll be requested interactively.
709 .UNINDENT
710 .INDENT 0.0
711 .TP
712 .B \-\-subcert=<KEYPATH>:<CERTPATH>[[;<PARAM>]...]
713 Specify  additional certificate  and  private key  file.
714 nghttpx will  choose certificates based on  the hostname
715 indicated by client using TLS SNI extension.  If nghttpx
716 is  built with  OpenSSL  >= 1.0.2,  the shared  elliptic
717 curves (e.g., P\-256) between  client and server are also
718 taken into  consideration.  This allows nghttpx  to send
719 ECDSA certificate  to modern clients, while  sending RSA
720 based certificate to older  clients.  This option can be
721 used  multiple  times.   To  make  OCSP  stapling  work,
722 <CERTPATH> must be absolute path.
723 .sp
724 Additional parameter  can be specified in  <PARAM>.  The
725 available <PARAM> is "sct\-dir=<DIR>".
726 .sp
727 "sct\-dir=<DIR>"  specifies the  path to  directory which
728 contains        *.sct        files        for        TLS
729 signed_certificate_timestamp extension (RFC 6962).  This
730 feature   requires   OpenSSL   >=   1.0.2.    See   also
731 \fI\%\-\-tls\-sct\-dir\fP option.
732 .UNINDENT
733 .INDENT 0.0
734 .TP
735 .B \-\-dh\-param\-file=<PATH>
736 Path to file that contains  DH parameters in PEM format.
737 Without  this   option,  DHE   cipher  suites   are  not
738 available.
739 .UNINDENT
740 .INDENT 0.0
741 .TP
742 .B \-\-npn\-list=<LIST>
743 Comma delimited list of  ALPN protocol identifier sorted
744 in the  order of preference.  That  means most desirable
745 protocol comes  first.  This  is used  in both  ALPN and
746 NPN.  The parameter must be  delimited by a single comma
747 only  and any  white spaces  are  treated as  a part  of
748 protocol string.
749 .sp
750 Default: \fBh2,h2\-16,h2\-14,http/1.1\fP
751 .UNINDENT
752 .INDENT 0.0
753 .TP
754 .B \-\-verify\-client
755 Require and verify client certificate.
756 .UNINDENT
757 .INDENT 0.0
758 .TP
759 .B \-\-verify\-client\-cacert=<PATH>
760 Path  to file  that contains  CA certificates  to verify
761 client certificate.  The file must be in PEM format.  It
762 can contain multiple certificates.
763 .UNINDENT
764 .INDENT 0.0
765 .TP
766 .B \-\-verify\-client\-tolerate\-expired
767 Accept  expired  client  certificate.   Operator  should
768 handle  the expired  client  certificate  by some  means
769 (e.g.,  mruby  script).   Otherwise, this  option  might
770 cause a security risk.
771 .UNINDENT
772 .INDENT 0.0
773 .TP
774 .B \-\-client\-private\-key\-file=<PATH>
775 Path to  file that contains  client private key  used in
776 backend client authentication.
777 .UNINDENT
778 .INDENT 0.0
779 .TP
780 .B \-\-client\-cert\-file=<PATH>
781 Path to  file that  contains client certificate  used in
782 backend client authentication.
783 .UNINDENT
784 .INDENT 0.0
785 .TP
786 .B \-\-tls\-min\-proto\-version=<VER>
787 Specify minimum SSL/TLS protocol.   The name matching is
788 done in  case\-insensitive manner.  The  versions between
789 \fI\%\-\-tls\-min\-proto\-version\fP and  \fI\%\-\-tls\-max\-proto\-version\fP are
790 enabled.  If the protocol list advertised by client does
791 not  overlap  this range,  you  will  receive the  error
792 message "unknown protocol".  If a protocol version lower
793 than TLSv1.2 is specified, make sure that the compatible
794 ciphers are  included in \fI\%\-\-ciphers\fP option.   The default
795 cipher  list  only   includes  ciphers  compatible  with
796 TLSv1.2 or above.  The available versions are:
797 TLSv1.3, TLSv1.2, TLSv1.1, and TLSv1.0
798 .sp
799 Default: \fBTLSv1.2\fP
800 .UNINDENT
801 .INDENT 0.0
802 .TP
803 .B \-\-tls\-max\-proto\-version=<VER>
804 Specify maximum SSL/TLS protocol.   The name matching is
805 done in  case\-insensitive manner.  The  versions between
806 \fI\%\-\-tls\-min\-proto\-version\fP and  \fI\%\-\-tls\-max\-proto\-version\fP are
807 enabled.  If the protocol list advertised by client does
808 not  overlap  this range,  you  will  receive the  error
809 message "unknown protocol".  The available versions are:
810 TLSv1.3, TLSv1.2, TLSv1.1, and TLSv1.0
811 .sp
812 Default: \fBTLSv1.3\fP
813 .UNINDENT
814 .INDENT 0.0
815 .TP
816 .B \-\-tls\-ticket\-key\-file=<PATH>
817 Path to file that contains  random data to construct TLS
818 session ticket  parameters.  If aes\-128\-cbc is  given in
819 \fI\%\-\-tls\-ticket\-key\-cipher\fP, the  file must  contain exactly
820 48    bytes.     If     aes\-256\-cbc    is    given    in
821 \fI\%\-\-tls\-ticket\-key\-cipher\fP, the  file must  contain exactly
822 80  bytes.   This  options  can be  used  repeatedly  to
823 specify  multiple ticket  parameters.  If  several files
824 are given,  only the  first key is  used to  encrypt TLS
825 session  tickets.  Other  keys are  accepted but  server
826 will  issue new  session  ticket with  first key.   This
827 allows  session  key  rotation.  Please  note  that  key
828 rotation  does  not  occur automatically.   User  should
829 rearrange  files or  change options  values and  restart
830 nghttpx gracefully.   If opening  or reading  given file
831 fails, all loaded  keys are discarded and  it is treated
832 as if none  of this option is given.  If  this option is
833 not given or an error  occurred while opening or reading
834 a file,  key is  generated every  1 hour  internally and
835 they are  valid for  12 hours.   This is  recommended if
836 ticket  key sharing  between  nghttpx  instances is  not
837 required.
838 .UNINDENT
839 .INDENT 0.0
840 .TP
841 .B \-\-tls\-ticket\-key\-memcached=<HOST>,<PORT>[;tls]
842 Specify address  of memcached  server to get  TLS ticket
843 keys for  session resumption.   This enables  shared TLS
844 ticket key between  multiple nghttpx instances.  nghttpx
845 does not set TLS ticket  key to memcached.  The external
846 ticket key generator is required.  nghttpx just gets TLS
847 ticket  keys  from  memcached, and  use  them,  possibly
848 replacing current set  of keys.  It is up  to extern TLS
849 ticket  key generator  to rotate  keys frequently.   See
850 "TLS SESSION  TICKET RESUMPTION" section in  manual page
851 to know the data format in memcached entry.  Optionally,
852 memcached  connection  can  be  encrypted  with  TLS  by
853 specifying "tls" parameter.
854 .UNINDENT
855 .INDENT 0.0
856 .TP
857 .B \-\-tls\-ticket\-key\-memcached\-address\-family=(auto|IPv4|IPv6)
858 Specify address  family of memcached connections  to get
859 TLS ticket keys.  If "auto" is given, both IPv4 and IPv6
860 are considered.   If "IPv4" is given,  only IPv4 address
861 is considered.  If "IPv6" is given, only IPv6 address is
862 considered.
863 .sp
864 Default: \fBauto\fP
865 .UNINDENT
866 .INDENT 0.0
867 .TP
868 .B \-\-tls\-ticket\-key\-memcached\-interval=<DURATION>
869 Set interval to get TLS ticket keys from memcached.
870 .sp
871 Default: \fB10m\fP
872 .UNINDENT
873 .INDENT 0.0
874 .TP
875 .B \-\-tls\-ticket\-key\-memcached\-max\-retry=<N>
876 Set  maximum   number  of  consecutive   retries  before
877 abandoning TLS ticket key  retrieval.  If this number is
878 reached,  the  attempt  is considered  as  failure,  and
879 "failure" count  is incremented by 1,  which contributed
880 to            the            value            controlled
881 \fI\%\-\-tls\-ticket\-key\-memcached\-max\-fail\fP option.
882 .sp
883 Default: \fB3\fP
884 .UNINDENT
885 .INDENT 0.0
886 .TP
887 .B \-\-tls\-ticket\-key\-memcached\-max\-fail=<N>
888 Set  maximum   number  of  consecutive   failure  before
889 disabling TLS ticket until next scheduled key retrieval.
890 .sp
891 Default: \fB2\fP
892 .UNINDENT
893 .INDENT 0.0
894 .TP
895 .B \-\-tls\-ticket\-key\-cipher=<CIPHER>
896 Specify cipher  to encrypt TLS session  ticket.  Specify
897 either   aes\-128\-cbc   or  aes\-256\-cbc.    By   default,
898 aes\-128\-cbc is used.
899 .UNINDENT
900 .INDENT 0.0
901 .TP
902 .B \-\-tls\-ticket\-key\-memcached\-cert\-file=<PATH>
903 Path to client certificate  for memcached connections to
904 get TLS ticket keys.
905 .UNINDENT
906 .INDENT 0.0
907 .TP
908 .B \-\-tls\-ticket\-key\-memcached\-private\-key\-file=<PATH>
909 Path to client private  key for memcached connections to
910 get TLS ticket keys.
911 .UNINDENT
912 .INDENT 0.0
913 .TP
914 .B \-\-fetch\-ocsp\-response\-file=<PATH>
915 Path to  fetch\-ocsp\-response script file.  It  should be
916 absolute path.
917 .sp
918 Default: \fB/usr/local/share/nghttp2/fetch\-ocsp\-response\fP
919 .UNINDENT
920 .INDENT 0.0
921 .TP
922 .B \-\-ocsp\-update\-interval=<DURATION>
923 Set interval to update OCSP response cache.
924 .sp
925 Default: \fB4h\fP
926 .UNINDENT
927 .INDENT 0.0
928 .TP
929 .B \-\-ocsp\-startup
930 Start  accepting connections  after initial  attempts to
931 get OCSP responses  finish.  It does not  matter some of
932 the  attempts  fail.  This  feature  is  useful if  OCSP
933 responses   must    be   available    before   accepting
934 connections.
935 .UNINDENT
936 .INDENT 0.0
937 .TP
938 .B \-\-no\-verify\-ocsp
939 nghttpx does not verify OCSP response.
940 .UNINDENT
941 .INDENT 0.0
942 .TP
943 .B \-\-no\-ocsp
944 Disable OCSP stapling.
945 .UNINDENT
946 .INDENT 0.0
947 .TP
948 .B \-\-tls\-session\-cache\-memcached=<HOST>,<PORT>[;tls]
949 Specify  address of  memcached server  to store  session
950 cache.   This  enables   shared  session  cache  between
951 multiple   nghttpx  instances.    Optionally,  memcached
952 connection can be encrypted with TLS by specifying "tls"
953 parameter.
954 .UNINDENT
955 .INDENT 0.0
956 .TP
957 .B \-\-tls\-session\-cache\-memcached\-address\-family=(auto|IPv4|IPv6)
958 Specify address family of memcached connections to store
959 session cache.  If  "auto" is given, both  IPv4 and IPv6
960 are considered.   If "IPv4" is given,  only IPv4 address
961 is considered.  If "IPv6" is given, only IPv6 address is
962 considered.
963 .sp
964 Default: \fBauto\fP
965 .UNINDENT
966 .INDENT 0.0
967 .TP
968 .B \-\-tls\-session\-cache\-memcached\-cert\-file=<PATH>
969 Path to client certificate  for memcached connections to
970 store session cache.
971 .UNINDENT
972 .INDENT 0.0
973 .TP
974 .B \-\-tls\-session\-cache\-memcached\-private\-key\-file=<PATH>
975 Path to client private  key for memcached connections to
976 store session cache.
977 .UNINDENT
978 .INDENT 0.0
979 .TP
980 .B \-\-tls\-dyn\-rec\-warmup\-threshold=<SIZE>
981 Specify the  threshold size for TLS  dynamic record size
982 behaviour.  During  a TLS  session, after  the threshold
983 number of bytes  have been written, the  TLS record size
984 will be increased to the maximum allowed (16K).  The max
985 record size will  continue to be used on  the active TLS
986 session.  After  \fI\%\-\-tls\-dyn\-rec\-idle\-timeout\fP has elapsed,
987 the record size is reduced  to 1300 bytes.  Specify 0 to
988 always use  the maximum record size,  regardless of idle
989 period.   This  behaviour  applies   to  all  TLS  based
990 frontends, and TLS HTTP/2 backends.
991 .sp
992 Default: \fB1M\fP
993 .UNINDENT
994 .INDENT 0.0
995 .TP
996 .B \-\-tls\-dyn\-rec\-idle\-timeout=<DURATION>
997 Specify TLS dynamic record  size behaviour timeout.  See
998 \fI\%\-\-tls\-dyn\-rec\-warmup\-threshold\fP  for   more  information.
999 This behaviour  applies to all TLS  based frontends, and
1000 TLS HTTP/2 backends.
1001 .sp
1002 Default: \fB1s\fP
1003 .UNINDENT
1004 .INDENT 0.0
1005 .TP
1006 .B \-\-no\-http2\-cipher\-black\-list
1007 Allow  black  listed  cipher suite  on  frontend  HTTP/2
1008 connection.                                          See
1009 \fI\%https://tools.ietf.org/html/rfc7540#appendix\-A\fP  for  the
1010 complete HTTP/2 cipher suites black list.
1011 .UNINDENT
1012 .INDENT 0.0
1013 .TP
1014 .B \-\-client\-no\-http2\-cipher\-black\-list
1015 Allow  black  listed  cipher  suite  on  backend  HTTP/2
1016 connection.                                          See
1017 \fI\%https://tools.ietf.org/html/rfc7540#appendix\-A\fP  for  the
1018 complete HTTP/2 cipher suites black list.
1019 .UNINDENT
1020 .INDENT 0.0
1021 .TP
1022 .B \-\-tls\-sct\-dir=<DIR>
1023 Specifies the  directory where  *.sct files  exist.  All
1024 *.sct   files   in  <DIR>   are   read,   and  sent   as
1025 extension_data of  TLS signed_certificate_timestamp (RFC
1026 6962)  to  client.   These   *.sct  files  are  for  the
1027 certificate   specified   in   positional   command\-line
1028 argument <CERT>, or  certificate option in configuration
1029 file.   For   additional  certificates,   use  \fI\%\-\-subcert\fP
1030 option.  This option requires OpenSSL >= 1.0.2.
1031 .UNINDENT
1032 .INDENT 0.0
1033 .TP
1034 .B \-\-psk\-secrets=<PATH>
1035 Read list of PSK identity and secrets from <PATH>.  This
1036 is used for frontend connection.  The each line of input
1037 file  is  formatted  as  <identity>:<hex\-secret>,  where
1038 <identity> is  PSK identity, and <hex\-secret>  is secret
1039 in hex.  An  empty line, and line which  starts with \(aq#\(aq
1040 are skipped.  The default  enabled cipher list might not
1041 contain any PSK cipher suite.  In that case, desired PSK
1042 cipher suites  must be  enabled using  \fI\%\-\-ciphers\fP option.
1043 The  desired PSK  cipher suite  may be  black listed  by
1044 HTTP/2.   To  use  those   cipher  suites  with  HTTP/2,
1045 consider  to  use  \fI\%\-\-no\-http2\-cipher\-black\-list\fP  option.
1046 But be aware its implications.
1047 .UNINDENT
1048 .INDENT 0.0
1049 .TP
1050 .B \-\-client\-psk\-secrets=<PATH>
1051 Read PSK identity and secrets from <PATH>.  This is used
1052 for backend connection.  The each  line of input file is
1053 formatted  as <identity>:<hex\-secret>,  where <identity>
1054 is PSK identity, and <hex\-secret>  is secret in hex.  An
1055 empty line, and line which  starts with \(aq#\(aq are skipped.
1056 The first identity and  secret pair encountered is used.
1057 The default  enabled cipher  list might not  contain any
1058 PSK  cipher suite.   In  that case,  desired PSK  cipher
1059 suites  must be  enabled using  \fI\%\-\-client\-ciphers\fP option.
1060 The  desired PSK  cipher suite  may be  black listed  by
1061 HTTP/2.   To  use  those   cipher  suites  with  HTTP/2,
1062 consider   to  use   \fI\%\-\-client\-no\-http2\-cipher\-black\-list\fP
1063 option.  But be aware its implications.
1064 .UNINDENT
1065 .INDENT 0.0
1066 .TP
1067 .B \-\-tls\-no\-postpone\-early\-data
1068 By default,  nghttpx postpones forwarding  HTTP requests
1069 sent in early data, including those sent in partially in
1070 it, until TLS handshake finishes.  If all backend server
1071 recognizes "Early\-Data" header  field, using this option
1072 makes nghttpx  not postpone  forwarding request  and get
1073 full potential of 0\-RTT data.
1074 .UNINDENT
1075 .INDENT 0.0
1076 .TP
1077 .B \-\-tls\-max\-early\-data=<SIZE>
1078 Sets  the  maximum  amount  of 0\-RTT  data  that  server
1079 accepts.
1080 .sp
1081 Default: \fB16K\fP
1082 .UNINDENT
1083 .SS HTTP/2
1084 .INDENT 0.0
1085 .TP
1086 .B \-c, \-\-frontend\-http2\-max\-concurrent\-streams=<N>
1087 Set the maximum number of  the concurrent streams in one
1088 frontend HTTP/2 session.
1089 .sp
1090 Default: \fB100\fP
1091 .UNINDENT
1092 .INDENT 0.0
1093 .TP
1094 .B \-\-backend\-http2\-max\-concurrent\-streams=<N>
1095 Set the maximum number of  the concurrent streams in one
1096 backend  HTTP/2 session.   This sets  maximum number  of
1097 concurrent opened pushed streams.  The maximum number of
1098 concurrent requests are set by a remote server.
1099 .sp
1100 Default: \fB100\fP
1101 .UNINDENT
1102 .INDENT 0.0
1103 .TP
1104 .B \-\-frontend\-http2\-window\-size=<SIZE>
1105 Sets  the  per\-stream  initial  window  size  of  HTTP/2
1106 frontend connection.
1107 .sp
1108 Default: \fB65535\fP
1109 .UNINDENT
1110 .INDENT 0.0
1111 .TP
1112 .B \-\-frontend\-http2\-connection\-window\-size=<SIZE>
1113 Sets the  per\-connection window size of  HTTP/2 frontend
1114 connection.
1115 .sp
1116 Default: \fB65535\fP
1117 .UNINDENT
1118 .INDENT 0.0
1119 .TP
1120 .B \-\-backend\-http2\-window\-size=<SIZE>
1121 Sets  the   initial  window   size  of   HTTP/2  backend
1122 connection.
1123 .sp
1124 Default: \fB65535\fP
1125 .UNINDENT
1126 .INDENT 0.0
1127 .TP
1128 .B \-\-backend\-http2\-connection\-window\-size=<SIZE>
1129 Sets the  per\-connection window  size of  HTTP/2 backend
1130 connection.
1131 .sp
1132 Default: \fB2147483647\fP
1133 .UNINDENT
1134 .INDENT 0.0
1135 .TP
1136 .B \-\-http2\-no\-cookie\-crumbling
1137 Don\(aqt crumble cookie header field.
1138 .UNINDENT
1139 .INDENT 0.0
1140 .TP
1141 .B \-\-padding=<N>
1142 Add  at most  <N> bytes  to  a HTTP/2  frame payload  as
1143 padding.  Specify 0 to  disable padding.  This option is
1144 meant for debugging purpose  and not intended to enhance
1145 protocol security.
1146 .UNINDENT
1147 .INDENT 0.0
1148 .TP
1149 .B \-\-no\-server\-push
1150 Disable HTTP/2 server push.  Server push is supported by
1151 default mode and HTTP/2  frontend via Link header field.
1152 It is  also supported if  both frontend and  backend are
1153 HTTP/2 in default mode.  In  this case, server push from
1154 backend session is relayed  to frontend, and server push
1155 via Link header field is also supported.
1156 .UNINDENT
1157 .INDENT 0.0
1158 .TP
1159 .B \-\-frontend\-http2\-optimize\-write\-buffer\-size
1160 (Experimental) Enable write  buffer size optimization in
1161 frontend HTTP/2 TLS  connection.  This optimization aims
1162 to reduce  write buffer  size so  that it  only contains
1163 bytes  which can  send immediately.   This makes  server
1164 more responsive to prioritized HTTP/2 stream because the
1165 buffering  of lower  priority stream  is reduced.   This
1166 option is only effective on recent Linux platform.
1167 .UNINDENT
1168 .INDENT 0.0
1169 .TP
1170 .B \-\-frontend\-http2\-optimize\-window\-size
1171 (Experimental)   Automatically  tune   connection  level
1172 window size of frontend  HTTP/2 TLS connection.  If this
1173 feature is  enabled, connection window size  starts with
1174 the   default  window   size,   65535  bytes.    nghttpx
1175 automatically  adjusts connection  window size  based on
1176 TCP receiving  window size.  The maximum  window size is
1177 capped      by      the     value      specified      by
1178 \fI\%\-\-frontend\-http2\-connection\-window\-size\fP\&.     Since   the
1179 stream is subject to stream level window size, it should
1180 be adjusted using \fI\%\-\-frontend\-http2\-window\-size\fP option as
1181 well.   This option  is only  effective on  recent Linux
1182 platform.
1183 .UNINDENT
1184 .INDENT 0.0
1185 .TP
1186 .B \-\-frontend\-http2\-encoder\-dynamic\-table\-size=<SIZE>
1187 Specify the maximum dynamic  table size of HPACK encoder
1188 in the frontend HTTP/2 connection.  The decoder (client)
1189 specifies  the maximum  dynamic table  size it  accepts.
1190 Then the negotiated dynamic table size is the minimum of
1191 this option value and the value which client specified.
1192 .sp
1193 Default: \fB4K\fP
1194 .UNINDENT
1195 .INDENT 0.0
1196 .TP
1197 .B \-\-frontend\-http2\-decoder\-dynamic\-table\-size=<SIZE>
1198 Specify the maximum dynamic  table size of HPACK decoder
1199 in the frontend HTTP/2 connection.
1200 .sp
1201 Default: \fB4K\fP
1202 .UNINDENT
1203 .INDENT 0.0
1204 .TP
1205 .B \-\-backend\-http2\-encoder\-dynamic\-table\-size=<SIZE>
1206 Specify the maximum dynamic  table size of HPACK encoder
1207 in the backend HTTP/2 connection.  The decoder (backend)
1208 specifies  the maximum  dynamic table  size it  accepts.
1209 Then the negotiated dynamic table size is the minimum of
1210 this option value and the value which backend specified.
1211 .sp
1212 Default: \fB4K\fP
1213 .UNINDENT
1214 .INDENT 0.0
1215 .TP
1216 .B \-\-backend\-http2\-decoder\-dynamic\-table\-size=<SIZE>
1217 Specify the maximum dynamic  table size of HPACK decoder
1218 in the backend HTTP/2 connection.
1219 .sp
1220 Default: \fB4K\fP
1221 .UNINDENT
1222 .SS Mode
1223 .INDENT 0.0
1224 .TP
1225 .B (default mode)
1226 Accept  HTTP/2,  and  HTTP/1.1 over  SSL/TLS.   "no\-tls"
1227 parameter is  used in  \fI\%\-\-frontend\fP option,  accept HTTP/2
1228 and HTTP/1.1 over cleartext  TCP.  The incoming HTTP/1.1
1229 connection  can  be  upgraded  to  HTTP/2  through  HTTP
1230 Upgrade.
1231 .UNINDENT
1232 .INDENT 0.0
1233 .TP
1234 .B \-s, \-\-http2\-proxy
1235 Like default mode, but enable forward proxy.  This is so
1236 called HTTP/2 proxy mode.
1237 .UNINDENT
1238 .SS Logging
1239 .INDENT 0.0
1240 .TP
1241 .B \-L, \-\-log\-level=<LEVEL>
1242 Set the severity  level of log output.   <LEVEL> must be
1243 one of INFO, NOTICE, WARN, ERROR and FATAL.
1244 .sp
1245 Default: \fBNOTICE\fP
1246 .UNINDENT
1247 .INDENT 0.0
1248 .TP
1249 .B \-\-accesslog\-file=<PATH>
1250 Set path to write access log.  To reopen file, send USR1
1251 signal to nghttpx.
1252 .UNINDENT
1253 .INDENT 0.0
1254 .TP
1255 .B \-\-accesslog\-syslog
1256 Send  access log  to syslog.   If this  option is  used,
1257 \fI\%\-\-accesslog\-file\fP option is ignored.
1258 .UNINDENT
1259 .INDENT 0.0
1260 .TP
1261 .B \-\-accesslog\-format=<FORMAT>
1262 Specify  format  string  for access  log.   The  default
1263 format is combined format.   The following variables are
1264 available:
1265 .INDENT 7.0
1266 .IP \(bu 2
1267 $remote_addr: client IP address.
1268 .IP \(bu 2
1269 $time_local: local time in Common Log format.
1270 .IP \(bu 2
1271 $time_iso8601: local time in ISO 8601 format.
1272 .IP \(bu 2
1273 $request: HTTP request line.
1274 .IP \(bu 2
1275 $status: HTTP response status code.
1276 .IP \(bu 2
1277 $body_bytes_sent: the  number of bytes sent  to client
1278 as response body.
1279 .IP \(bu 2
1280 $http_<VAR>: value of HTTP  request header <VAR> where
1281 \(aq_\(aq in <VAR> is replaced with \(aq\-\(aq.
1282 .IP \(bu 2
1283 $remote_port: client  port.
1284 .IP \(bu 2
1285 $server_port: server port.
1286 .IP \(bu 2
1287 $request_time: request processing time in seconds with
1288 milliseconds resolution.
1289 .IP \(bu 2
1290 $pid: PID of the running process.
1291 .IP \(bu 2
1292 $alpn: ALPN identifier of the protocol which generates
1293 the response.   For HTTP/1,  ALPN is  always http/1.1,
1294 regardless of minor version.
1295 .IP \(bu 2
1296 $tls_cipher: cipher used for SSL/TLS connection.
1297 .IP \(bu 2
1298 $tls_client_fingerprint_sha256: SHA\-256 fingerprint of
1299 client certificate.
1300 .IP \(bu 2
1301 $tls_client_fingerprint_sha1:  SHA\-1   fingerprint  of
1302 client certificate.
1303 .IP \(bu 2
1304 $tls_client_subject_name:   subject  name   in  client
1305 certificate.
1306 .IP \(bu 2
1307 $tls_client_issuer_name:   issuer   name   in   client
1308 certificate.
1309 .IP \(bu 2
1310 $tls_client_serial:    serial    number   in    client
1311 certificate.
1312 .IP \(bu 2
1313 $tls_protocol: protocol for SSL/TLS connection.
1314 .IP \(bu 2
1315 $tls_session_id: session ID for SSL/TLS connection.
1316 .IP \(bu 2
1317 $tls_session_reused:  "r"   if  SSL/TLS   session  was
1318 reused.  Otherwise, "."
1319 .IP \(bu 2
1320 $tls_sni: SNI server name for SSL/TLS connection.
1321 .IP \(bu 2
1322 $backend_host:  backend  host   used  to  fulfill  the
1323 request.  "\-" if backend host is not available.
1324 .IP \(bu 2
1325 $backend_port:  backend  port   used  to  fulfill  the
1326 request.  "\-" if backend host is not available.
1327 .UNINDENT
1328 .sp
1329 The  variable  can  be  enclosed  by  "{"  and  "}"  for
1330 disambiguation (e.g., ${remote_addr}).
1331 .sp
1332 Default: \fB$remote_addr \- \- [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent"\fP
1333 .UNINDENT
1334 .INDENT 0.0
1335 .TP
1336 .B \-\-accesslog\-write\-early
1337 Write  access  log  when   response  header  fields  are
1338 received   from  backend   rather   than  when   request
1339 transaction finishes.
1340 .UNINDENT
1341 .INDENT 0.0
1342 .TP
1343 .B \-\-errorlog\-file=<PATH>
1344 Set path to write error  log.  To reopen file, send USR1
1345 signal  to nghttpx.   stderr will  be redirected  to the
1346 error log file unless \fI\%\-\-errorlog\-syslog\fP is used.
1347 .sp
1348 Default: \fB/dev/stderr\fP
1349 .UNINDENT
1350 .INDENT 0.0
1351 .TP
1352 .B \-\-errorlog\-syslog
1353 Send  error log  to  syslog.  If  this  option is  used,
1354 \fI\%\-\-errorlog\-file\fP option is ignored.
1355 .UNINDENT
1356 .INDENT 0.0
1357 .TP
1358 .B \-\-syslog\-facility=<FACILITY>
1359 Set syslog facility to <FACILITY>.
1360 .sp
1361 Default: \fBdaemon\fP
1362 .UNINDENT
1363 .SS HTTP
1364 .INDENT 0.0
1365 .TP
1366 .B \-\-add\-x\-forwarded\-for
1367 Append  X\-Forwarded\-For header  field to  the downstream
1368 request.
1369 .UNINDENT
1370 .INDENT 0.0
1371 .TP
1372 .B \-\-strip\-incoming\-x\-forwarded\-for
1373 Strip X\-Forwarded\-For  header field from  inbound client
1374 requests.
1375 .UNINDENT
1376 .INDENT 0.0
1377 .TP
1378 .B \-\-no\-add\-x\-forwarded\-proto
1379 Don\(aqt append  additional X\-Forwarded\-Proto  header field
1380 to  the   backend  request.   If  inbound   client  sets
1381 X\-Forwarded\-Proto,                                   and
1382 \fI\%\-\-no\-strip\-incoming\-x\-forwarded\-proto\fP  option  is  used,
1383 they are passed to the backend.
1384 .UNINDENT
1385 .INDENT 0.0
1386 .TP
1387 .B \-\-no\-strip\-incoming\-x\-forwarded\-proto
1388 Don\(aqt strip X\-Forwarded\-Proto  header field from inbound
1389 client requests.
1390 .UNINDENT
1391 .INDENT 0.0
1392 .TP
1393 .B \-\-add\-forwarded=<LIST>
1394 Append RFC  7239 Forwarded header field  with parameters
1395 specified in comma delimited list <LIST>.  The supported
1396 parameters  are "by",  "for", "host",  and "proto".   By
1397 default,  the value  of  "by" and  "for" parameters  are
1398 obfuscated     string.     See     \fI\%\-\-forwarded\-by\fP    and
1399 \fI\%\-\-forwarded\-for\fP options respectively.  Note that nghttpx
1400 does  not  translate non\-standard  X\-Forwarded\-*  header
1401 fields into Forwarded header field, and vice versa.
1402 .UNINDENT
1403 .INDENT 0.0
1404 .TP
1405 .B \-\-strip\-incoming\-forwarded
1406 Strip  Forwarded   header  field  from   inbound  client
1407 requests.
1408 .UNINDENT
1409 .INDENT 0.0
1410 .TP
1411 .B \-\-forwarded\-by=(obfuscated|ip|<VALUE>)
1412 Specify the parameter value sent out with "by" parameter
1413 of Forwarded  header field.   If "obfuscated"  is given,
1414 the string is randomly generated at startup.  If "ip" is
1415 given,   the  interface   address  of   the  connection,
1416 including port number, is  sent with "by" parameter.  In
1417 case of UNIX domain  socket, "localhost" is used instead
1418 of address and  port.  User can also  specify the static
1419 obfuscated string.  The limitation is that it must start
1420 with   "_",  and   only   consists   of  character   set
1421 [A\-Za\-z0\-9._\-], as described in RFC 7239.
1422 .sp
1423 Default: \fBobfuscated\fP
1424 .UNINDENT
1425 .INDENT 0.0
1426 .TP
1427 .B \-\-forwarded\-for=(obfuscated|ip)
1428 Specify  the   parameter  value  sent  out   with  "for"
1429 parameter of Forwarded header field.  If "obfuscated" is
1430 given, the string is  randomly generated for each client
1431 connection.  If "ip" is given, the remote client address
1432 of  the connection,  without port  number, is  sent with
1433 "for"  parameter.   In  case   of  UNIX  domain  socket,
1434 "localhost" is used instead of address.
1435 .sp
1436 Default: \fBobfuscated\fP
1437 .UNINDENT
1438 .INDENT 0.0
1439 .TP
1440 .B \-\-no\-via
1441 Don\(aqt append to  Via header field.  If  Via header field
1442 is received, it is left unaltered.
1443 .UNINDENT
1444 .INDENT 0.0
1445 .TP
1446 .B \-\-no\-strip\-incoming\-early\-data
1447 Don\(aqt strip Early\-Data header  field from inbound client
1448 requests.
1449 .UNINDENT
1450 .INDENT 0.0
1451 .TP
1452 .B \-\-no\-location\-rewrite
1453 Don\(aqt  rewrite location  header field  in default  mode.
1454 When \fI\%\-\-http2\-proxy\fP  is used, location header  field will
1455 not be altered regardless of this option.
1456 .UNINDENT
1457 .INDENT 0.0
1458 .TP
1459 .B \-\-host\-rewrite
1460 Rewrite  host and  :authority header  fields in  default
1461 mode.  When  \fI\%\-\-http2\-proxy\fP is  used, these  headers will
1462 not be altered regardless of this option.
1463 .UNINDENT
1464 .INDENT 0.0
1465 .TP
1466 .B \-\-altsvc=<PROTOID,PORT[,HOST,[ORIGIN]]>
1467 Specify   protocol  ID,   port,  host   and  origin   of
1468 alternative service.  <HOST>  and <ORIGIN> are optional.
1469 They  are advertised  in  alt\-svc header  field only  in
1470 HTTP/1.1  frontend.  This  option can  be used  multiple
1471 times   to   specify  multiple   alternative   services.
1472 Example: \fI\%\-\-altsvc\fP=h2,443
1473 .UNINDENT
1474 .INDENT 0.0
1475 .TP
1476 .B \-\-add\-request\-header=<HEADER>
1477 Specify additional header field to add to request header
1478 set.  This  option just  appends header field  and won\(aqt
1479 replace anything  already set.  This option  can be used
1480 several  times   to  specify  multiple   header  fields.
1481 Example: \fI\%\-\-add\-request\-header\fP="foo: bar"
1482 .UNINDENT
1483 .INDENT 0.0
1484 .TP
1485 .B \-\-add\-response\-header=<HEADER>
1486 Specify  additional  header  field to  add  to  response
1487 header set.   This option just appends  header field and
1488 won\(aqt replace anything already  set.  This option can be
1489 used several  times to  specify multiple  header fields.
1490 Example: \fI\%\-\-add\-response\-header\fP="foo: bar"
1491 .UNINDENT
1492 .INDENT 0.0
1493 .TP
1494 .B \-\-request\-header\-field\-buffer=<SIZE>
1495 Set maximum buffer size for incoming HTTP request header
1496 field list.  This is the sum of header name and value in
1497 bytes.   If  trailer  fields  exist,  they  are  counted
1498 towards this number.
1499 .sp
1500 Default: \fB64K\fP
1501 .UNINDENT
1502 .INDENT 0.0
1503 .TP
1504 .B \-\-max\-request\-header\-fields=<N>
1505 Set  maximum  number  of incoming  HTTP  request  header
1506 fields.   If  trailer  fields exist,  they  are  counted
1507 towards this number.
1508 .sp
1509 Default: \fB100\fP
1510 .UNINDENT
1511 .INDENT 0.0
1512 .TP
1513 .B \-\-response\-header\-field\-buffer=<SIZE>
1514 Set  maximum  buffer  size for  incoming  HTTP  response
1515 header field list.   This is the sum of  header name and
1516 value  in  bytes.  If  trailer  fields  exist, they  are
1517 counted towards this number.
1518 .sp
1519 Default: \fB64K\fP
1520 .UNINDENT
1521 .INDENT 0.0
1522 .TP
1523 .B \-\-max\-response\-header\-fields=<N>
1524 Set  maximum number  of  incoming  HTTP response  header
1525 fields.   If  trailer  fields exist,  they  are  counted
1526 towards this number.
1527 .sp
1528 Default: \fB500\fP
1529 .UNINDENT
1530 .INDENT 0.0
1531 .TP
1532 .B \-\-error\-page=(<CODE>|*)=<PATH>
1533 Set file path  to custom error page  served when nghttpx
1534 originally  generates  HTTP  error status  code  <CODE>.
1535 <CODE> must be greater than or equal to 400, and at most
1536 599.  If "*"  is used instead of <CODE>,  it matches all
1537 HTTP  status  code.  If  error  status  code comes  from
1538 backend server, the custom error pages are not used.
1539 .UNINDENT
1540 .INDENT 0.0
1541 .TP
1542 .B \-\-server\-name=<NAME>
1543 Change server response header field value to <NAME>.
1544 .sp
1545 Default: \fBnghttpx\fP
1546 .UNINDENT
1547 .INDENT 0.0
1548 .TP
1549 .B \-\-no\-server\-rewrite
1550 Don\(aqt rewrite server header field in default mode.  When
1551 \fI\%\-\-http2\-proxy\fP is used, these headers will not be altered
1552 regardless of this option.
1553 .UNINDENT
1554 .INDENT 0.0
1555 .TP
1556 .B \-\-redirect\-https\-port=<PORT>
1557 Specify the port number which appears in Location header
1558 field  when  redirect  to  HTTPS  URI  is  made  due  to
1559 "redirect\-if\-not\-tls" parameter in \fI\%\-\-backend\fP option.
1560 .sp
1561 Default: \fB443\fP
1562 .UNINDENT
1563 .SS API
1564 .INDENT 0.0
1565 .TP
1566 .B \-\-api\-max\-request\-body=<SIZE>
1567 Set the maximum size of request body for API request.
1568 .sp
1569 Default: \fB32M\fP
1570 .UNINDENT
1571 .SS DNS
1572 .INDENT 0.0
1573 .TP
1574 .B \-\-dns\-cache\-timeout=<DURATION>
1575 Set duration that cached DNS results remain valid.  Note
1576 that nghttpx caches the unsuccessful results as well.
1577 .sp
1578 Default: \fB10s\fP
1579 .UNINDENT
1580 .INDENT 0.0
1581 .TP
1582 .B \-\-dns\-lookup\-timeout=<DURATION>
1583 Set timeout that  DNS server is given to  respond to the
1584 initial  DNS  query.  For  the  2nd  and later  queries,
1585 server is  given time based  on this timeout, and  it is
1586 scaled linearly.
1587 .sp
1588 Default: \fB5s\fP
1589 .UNINDENT
1590 .INDENT 0.0
1591 .TP
1592 .B \-\-dns\-max\-try=<N>
1593 Set the number of DNS query before nghttpx gives up name
1594 lookup.
1595 .sp
1596 Default: \fB2\fP
1597 .UNINDENT
1598 .INDENT 0.0
1599 .TP
1600 .B \-\-frontend\-max\-requests=<N>
1601 The number  of requests that single  frontend connection
1602 can process.  For HTTP/2, this  is the number of streams
1603 in  one  HTTP/2 connection.   For  HTTP/1,  this is  the
1604 number of keep alive requests.  This is hint to nghttpx,
1605 and it  may allow additional few  requests.  The default
1606 value is unlimited.
1607 .UNINDENT
1608 .SS Debug
1609 .INDENT 0.0
1610 .TP
1611 .B \-\-frontend\-http2\-dump\-request\-header=<PATH>
1612 Dumps request headers received by HTTP/2 frontend to the
1613 file denoted  in <PATH>.  The  output is done  in HTTP/1
1614 header field format and each header block is followed by
1615 an empty line.  This option  is not thread safe and MUST
1616 NOT be used with option \fI\%\-n\fP<N>, where <N> >= 2.
1617 .UNINDENT
1618 .INDENT 0.0
1619 .TP
1620 .B \-\-frontend\-http2\-dump\-response\-header=<PATH>
1621 Dumps response headers sent  from HTTP/2 frontend to the
1622 file denoted  in <PATH>.  The  output is done  in HTTP/1
1623 header field format and each header block is followed by
1624 an empty line.  This option  is not thread safe and MUST
1625 NOT be used with option \fI\%\-n\fP<N>, where <N> >= 2.
1626 .UNINDENT
1627 .INDENT 0.0
1628 .TP
1629 .B \-o, \-\-frontend\-frame\-debug
1630 Print HTTP/2 frames in  frontend to stderr.  This option
1631 is  not thread  safe and  MUST NOT  be used  with option
1632 \fI\%\-n\fP=N, where N >= 2.
1633 .UNINDENT
1634 .SS Process
1635 .INDENT 0.0
1636 .TP
1637 .B \-D, \-\-daemon
1638 Run in a background.  If \fI\%\-D\fP is used, the current working
1639 directory is changed to \(aq\fI/\fP\(aq.
1640 .UNINDENT
1641 .INDENT 0.0
1642 .TP
1643 .B \-\-pid\-file=<PATH>
1644 Set path to save PID of this program.
1645 .UNINDENT
1646 .INDENT 0.0
1647 .TP
1648 .B \-\-user=<USER>
1649 Run this program as <USER>.   This option is intended to
1650 be used to drop root privileges.
1651 .UNINDENT
1652 .INDENT 0.0
1653 .TP
1654 .B \-\-single\-process
1655 Run this program in a  single process mode for debugging
1656 purpose.  Without this option,  nghttpx creates at least
1657 2  processes:  master  and worker  processes.   If  this
1658 option is  used, master  and worker  are unified  into a
1659 single process.  nghttpx still spawns additional process
1660 if neverbleed is used.  In  the single process mode, the
1661 signal handling feature is disabled.
1662 .UNINDENT
1663 .SS Scripting
1664 .INDENT 0.0
1665 .TP
1666 .B \-\-mruby\-file=<PATH>
1667 Set mruby script file
1668 .UNINDENT
1669 .INDENT 0.0
1670 .TP
1671 .B \-\-ignore\-per\-pattern\-mruby\-error
1672 Ignore mruby compile error  for per\-pattern mruby script
1673 file.  If error  occurred, it is treated as  if no mruby
1674 file were specified for the pattern.
1675 .UNINDENT
1676 .SS Misc
1677 .INDENT 0.0
1678 .TP
1679 .B \-\-conf=<PATH>
1680 Load  configuration  from   <PATH>.   Please  note  that
1681 nghttpx always  tries to read the  default configuration
1682 file if \fI\%\-\-conf\fP is not given.
1683 .sp
1684 Default: \fB/etc/nghttpx/nghttpx.conf\fP
1685 .UNINDENT
1686 .INDENT 0.0
1687 .TP
1688 .B \-\-include=<PATH>
1689 Load additional configurations from <PATH>.  File <PATH>
1690 is  read  when  configuration  parser  encountered  this
1691 option.  This option can be used multiple times, or even
1692 recursively.
1693 .UNINDENT
1694 .INDENT 0.0
1695 .TP
1696 .B \-v, \-\-version
1697 Print version and exit.
1698 .UNINDENT
1699 .INDENT 0.0
1700 .TP
1701 .B \-h, \-\-help
1702 Print this help and exit.
1703 .UNINDENT
1704 .sp
1705 The <SIZE> argument is an integer and an optional unit (e.g., 10K is
1706 10 * 1024).  Units are K, M and G (powers of 1024).
1707 .sp
1708 The <DURATION> argument is an integer and an optional unit (e.g., 1s
1709 is 1 second and 500ms is 500 milliseconds).  Units are h, m, s or ms
1710 (hours, minutes, seconds and milliseconds, respectively).  If a unit
1711 is omitted, a second is used as unit.
1712 .SH FILES
1713 .INDENT 0.0
1714 .TP
1715 .B \fI/etc/nghttpx/nghttpx.conf\fP
1716 The default configuration file path nghttpx searches at startup.
1717 The configuration file path can be changed using \fI\%\-\-conf\fP
1718 option.
1719 .sp
1720 Those lines which are staring \fB#\fP are treated as comment.
1721 .sp
1722 The option name in the configuration file is the long command\-line
1723 option name with leading \fB\-\-\fP stripped (e.g., \fBfrontend\fP).  Put
1724 \fB=\fP between option name and value.  Don\(aqt put extra leading or
1725 trailing spaces.
1726 .sp
1727 When specifying arguments including characters which have special
1728 meaning to a shell, we usually use quotes so that shell does not
1729 interpret them.  When writing this configuration file, quotes for
1730 this purpose must not be used.  For example, specify additional
1731 request header field, do this:
1732 .INDENT 7.0
1733 .INDENT 3.5
1734 .sp
1735 .nf
1736 .ft C
1737 add\-request\-header=foo: bar
1738 .ft P
1739 .fi
1740 .UNINDENT
1741 .UNINDENT
1742 .sp
1743 instead of:
1744 .INDENT 7.0
1745 .INDENT 3.5
1746 .sp
1747 .nf
1748 .ft C
1749 add\-request\-header="foo: bar"
1750 .ft P
1751 .fi
1752 .UNINDENT
1753 .UNINDENT
1754 .sp
1755 The options which do not take argument in the command\-line \fItake\fP
1756 argument in the configuration file.  Specify \fByes\fP as an argument
1757 (e.g., \fBhttp2\-proxy=yes\fP).  If other string is given, it is
1758 ignored.
1759 .sp
1760 To specify private key and certificate file which are given as
1761 positional arguments in command\-line, use \fBprivate\-key\-file\fP and
1762 \fBcertificate\-file\fP\&.
1763 .sp
1764 \fI\%\-\-conf\fP option cannot be used in the configuration file and
1765 will be ignored if specified.
1766 .TP
1767 .B Error log
1768 Error log is written to stderr by default.  It can be configured
1769 using \fI\%\-\-errorlog\-file\fP\&.  The format of log message is as
1770 follows:
1771 .sp
1772 <datetime> <master\-pid> <current\-pid> <thread\-id> <level> (<filename>:<line>) <msg>
1773 .INDENT 7.0
1774 .TP
1775 .B <datetime>
1776 It is a combination of date and time when the log is written.  It
1777 is in ISO 8601 format.
1778 .TP
1779 .B <master\-pid>
1780 It is a master process ID.
1781 .TP
1782 .B <current\-pid>
1783 It is a process ID which writes this log.
1784 .TP
1785 .B <thread\-id>
1786 It is a thread ID which writes this log.  It would be unique
1787 within <current\-pid>.
1788 .TP
1789 .B <filename> and <line>
1790 They are source file name, and line number which produce this log.
1791 .TP
1792 .B <msg>
1793 It is a log message body.
1794 .UNINDENT
1795 .UNINDENT
1796 .SH SIGNALS
1797 .INDENT 0.0
1798 .TP
1799 .B SIGQUIT
1800 Shutdown gracefully.  First accept pending connections and stop
1801 accepting connection.  After all connections are handled, nghttpx
1802 exits.
1803 .TP
1804 .B SIGHUP
1805 Reload configuration file given in \fI\%\-\-conf\fP\&.
1806 .TP
1807 .B SIGUSR1
1808 Reopen log files.
1809 .UNINDENT
1810 .sp
1811 SIGUSR2
1812 .INDENT 0.0
1813 .INDENT 3.5
1814 Fork and execute nghttpx.  It will execute the binary in the same
1815 path with same command\-line arguments and environment variables.  As
1816 of nghttpx version 1.20.0, the new master process sends SIGQUIT to
1817 the original master process when it is ready to serve requests.  For
1818 the earlier versions of nghttpx, user has to send SIGQUIT to the
1819 original master process.
1820 .sp
1821 The difference between SIGUSR2 (+ SIGQUIT) and SIGHUP is that former
1822 is usually used to execute new binary, and the master process is
1823 newly spawned.  On the other hand, the latter just reloads
1824 configuration file, and the same master process continues to exist.
1825 .UNINDENT
1826 .UNINDENT
1827 .sp
1828 \fBNOTE:\fP
1829 .INDENT 0.0
1830 .INDENT 3.5
1831 nghttpx consists of multiple processes: one process for processing
1832 these signals, and another one for processing requests.  The former
1833 spawns the latter.  The former is called master process, and the
1834 latter is called worker process.  If neverbleed is enabled, the
1835 worker process spawns neverbleed daemon process which does RSA key
1836 processing.  The above signal must be sent to the master process.
1837 If the other processes received one of them, it is ignored.  This
1838 behaviour of these processes may change in the future release.  In
1839 other words, in the future release, the processes other than master
1840 process may terminate upon the reception of these signals.
1841 Therefore these signals should not be sent to the processes other
1842 than master process.
1843 .UNINDENT
1844 .UNINDENT
1845 .SH SERVER PUSH
1846 .sp
1847 nghttpx supports HTTP/2 server push in default mode with Link header
1848 field.  nghttpx looks for Link header field (\fI\%RFC 5988\fP) in response headers from
1849 backend server and extracts URI\-reference with parameter
1850 \fBrel=preload\fP (see \fI\%preload\fP)
1851 and pushes those URIs to the frontend client. Here is a sample Link
1852 header field to initiate server push:
1853 .INDENT 0.0
1854 .INDENT 3.5
1855 .sp
1856 .nf
1857 .ft C
1858 Link: </fonts/font.woff>; rel=preload
1859 Link: </css/theme.css>; rel=preload
1860 .ft P
1861 .fi
1862 .UNINDENT
1863 .UNINDENT
1864 .sp
1865 Currently, the following restriction is applied for server push:
1866 .INDENT 0.0
1867 .IP 1. 3
1868 The associated stream must have method "GET" or "POST".  The
1869 associated stream\(aqs status code must be 200.
1870 .UNINDENT
1871 .sp
1872 This limitation may be loosened in the future release.
1873 .sp
1874 nghttpx also supports server push if both frontend and backend are
1875 HTTP/2 in default mode.  In this case, in addition to server push via
1876 Link header field, server push from backend is forwarded to frontend
1877 HTTP/2 session.
1878 .sp
1879 HTTP/2 server push will be disabled if \fI\%\-\-http2\-proxy\fP is
1880 used.
1881 .SH UNIX DOMAIN SOCKET
1882 .sp
1883 nghttpx supports UNIX domain socket with a filename for both frontend
1884 and backend connections.
1885 .sp
1886 Please note that current nghttpx implementation does not delete a
1887 socket with a filename.  And on start up, if nghttpx detects that the
1888 specified socket already exists in the file system, nghttpx first
1889 deletes it.  However, if SIGUSR2 is used to execute new binary and
1890 both old and new configurations use same filename, new binary does not
1891 delete the socket and continues to use it.
1892 .SH OCSP STAPLING
1893 .sp
1894 OCSP query is done using external Python script
1895 \fBfetch\-ocsp\-response\fP, which has been originally developed in Perl
1896 as part of h2o project (\fI\%https://github.com/h2o/h2o\fP), and was
1897 translated into Python.
1898 .sp
1899 The script file is usually installed under
1900 \fB$(prefix)/share/nghttp2/\fP directory.  The actual path to script can
1901 be customized using \fI\%\-\-fetch\-ocsp\-response\-file\fP option.
1902 .sp
1903 If OCSP query is failed, previous OCSP response, if any, is continued
1904 to be used.
1905 .sp
1906 \fI\%\-\-fetch\-ocsp\-response\-file\fP option provides wide range of
1907 possibility to manage OCSP response.  It can take an arbitrary script
1908 or executable.  The requirement is that it supports the command\-line
1909 interface of \fBfetch\-ocsp\-response\fP script, and it must return a
1910 valid DER encoded OCSP response on success.  It must return exit code
1911 0 on success, and 75 for temporary error, and the other error code for
1912 generic failure.  For large cluster of servers, it is not efficient
1913 for each server to perform OCSP query using \fBfetch\-ocsp\-response\fP\&.
1914 Instead, you can retrieve OCSP response in some way, and store it in a
1915 disk or a shared database.  Then specify a program in
1916 \fI\%\-\-fetch\-ocsp\-response\-file\fP to fetch it from those stores.
1917 This could provide a way to share the OCSP response between fleet of
1918 servers, and also any OCSP query strategy can be applied which may be
1919 beyond the ability of nghttpx itself or \fBfetch\-ocsp\-response\fP
1920 script.
1921 .SH TLS SESSION RESUMPTION
1922 .sp
1923 nghttpx supports TLS session resumption through both session ID and
1924 session ticket.
1925 .SS SESSION ID RESUMPTION
1926 .sp
1927 By default, session ID is shared by all worker threads.
1928 .sp
1929 If \fI\%\-\-tls\-session\-cache\-memcached\fP is given, nghttpx will
1930 insert serialized session data to memcached with
1931 \fBnghttpx:tls\-session\-cache:\fP + lowercase hex string of session ID
1932 as a memcached entry key, with expiry time 12 hours.  Session timeout
1933 is set to 12 hours.
1934 .sp
1935 By default, connections to memcached server are not encrypted.  To
1936 enable encryption, use \fBtls\fP keyword in
1937 \fI\%\-\-tls\-session\-cache\-memcached\fP option.
1938 .SS TLS SESSION TICKET RESUMPTION
1939 .sp
1940 By default, session ticket is shared by all worker threads.  The
1941 automatic key rotation is also enabled by default.  Every an hour, new
1942 encryption key is generated, and previous encryption key becomes
1943 decryption only key.  We set session timeout to 12 hours, and thus we
1944 keep at most 12 keys.
1945 .sp
1946 If \fI\%\-\-tls\-ticket\-key\-memcached\fP is given, encryption keys are
1947 retrieved from memcached.  nghttpx just reads keys from memcached; one
1948 has to deploy key generator program to update keys frequently (e.g.,
1949 every 1 hour).  The example key generator tlsticketupdate.go is
1950 available under contrib directory in nghttp2 archive.  The memcached
1951 entry key is \fBnghttpx:tls\-ticket\-key\fP\&.  The data format stored in
1952 memcached is the binary format described below:
1953 .INDENT 0.0
1954 .INDENT 3.5
1955 .sp
1956 .nf
1957 .ft C
1958 +\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+
1959 | VERSION (4)  |LEN (2)|KEY(48 or 80) ...
1960 +\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+
1961                ^                        |
1962                |                        |
1963                +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+
1964                (LEN, KEY) pair can be repeated
1965 .ft P
1966 .fi
1967 .UNINDENT
1968 .UNINDENT
1969 .sp
1970 All numbers in the above figure is bytes.  All integer fields are
1971 network byte order.
1972 .sp
1973 First 4 bytes integer VERSION field, which must be 1.  The 2 bytes
1974 integer LEN field gives the length of following KEY field, which
1975 contains key.  If \fI\%\-\-tls\-ticket\-key\-cipher\fP=aes\-128\-cbc is
1976 used, LEN must be 48.  If
1977 \fI\%\-\-tls\-ticket\-key\-cipher\fP=aes\-256\-cbc is used, LEN must be
1978 80.  LEN and KEY pair can be repeated multiple times to store multiple
1979 keys.  The key appeared first is used as encryption key.  All the
1980 remaining keys are used as decryption only.
1981 .sp
1982 By default, connections to memcached server are not encrypted.  To
1983 enable encryption, use \fBtls\fP keyword in
1984 \fI\%\-\-tls\-ticket\-key\-memcached\fP option.
1985 .sp
1986 If \fI\%\-\-tls\-ticket\-key\-file\fP is given, encryption key is read
1987 from the given file.  In this case, nghttpx does not rotate key
1988 automatically.  To rotate key, one has to restart nghttpx (see
1989 SIGNALS).
1990 .SH CERTIFICATE TRANSPARENCY
1991 .sp
1992 nghttpx supports TLS \fBsigned_certificate_timestamp\fP extension (\fI\%RFC
1993 6962\fP).  The relevant options
1994 are \fI\%\-\-tls\-sct\-dir\fP and \fBsct\-dir\fP parameter in
1995 \fI\%\-\-subcert\fP\&.  They takes a directory, and nghttpx reads all
1996 files whose extension is \fB\&.sct\fP under the directory.  The \fB*.sct\fP
1997 files are encoded as \fBSignedCertificateTimestamp\fP struct described
1998 in \fI\%section 3.2 of RFC 69662\fP\&.  This format is
1999 the same one used by \fI\%nginx\-ct\fP and \fI\%mod_ssl_ct\fP\&.
2000 \fI\%ct\-submit\fP can be
2001 used to submit certificates to log servers, and obtain the
2002 \fBSignedCertificateTimestamp\fP struct which can be used with nghttpx.
2003 .SH MRUBY SCRIPTING
2004 .sp
2005 \fBWARNING:\fP
2006 .INDENT 0.0
2007 .INDENT 3.5
2008 The current mruby extension API is experimental and not frozen.  The
2009 API is subject to change in the future release.
2010 .UNINDENT
2011 .UNINDENT
2012 .sp
2013 \fBWARNING:\fP
2014 .INDENT 0.0
2015 .INDENT 3.5
2016 Almost all string value returned from method, or attribute is a
2017 fresh new mruby string, which involves memory allocation, and
2018 copies.  Therefore, it is strongly recommended to store a return
2019 value in a local variable, and use it, instead of calling method or
2020 accessing attribute repeatedly.
2021 .UNINDENT
2022 .UNINDENT
2023 .sp
2024 nghttpx allows users to extend its capability using mruby scripts.
2025 nghttpx has 2 hook points to execute mruby script: request phase and
2026 response phase.  The request phase hook is invoked after all request
2027 header fields are received from client.  The response phase hook is
2028 invoked after all response header fields are received from backend
2029 server.  These hooks allows users to modify header fields, or common
2030 HTTP variables, like authority or request path, and even return custom
2031 response without forwarding request to backend servers.
2032 .sp
2033 There are 2 levels of mruby script invocations: global and
2034 per\-pattern.  The global mruby script is set by \fI\%\-\-mruby\-file\fP
2035 option and is called for all requests.  The per\-pattern mruby script
2036 is set by "mruby" parameter in \fI\%\-b\fP option.  It is invoked for
2037 a request which matches the particular pattern.  The order of hook
2038 invocation is: global request phase hook, per\-pattern request phase
2039 hook, per\-pattern response phase hook, and finally global response
2040 phase hook.  If a hook returns a response, any later hooks are not
2041 invoked.  The global request hook is invoked before the pattern
2042 matching is made and changing request path may affect the pattern
2043 matching.
2044 .sp
2045 Please note that request and response hooks of per\-pattern mruby
2046 script for a single request might not come from the same script.  This
2047 might happen after a request hook is executed, backend failed for some
2048 reason, and at the same time, backend configuration is replaced by API
2049 request, and then the request uses new configuration on retry.  The
2050 response hook from new configuration, if it is specified, will be
2051 invoked.
2052 .sp
2053 The all mruby script will be evaluated once per thread on startup, and
2054 it must instantiate object and evaluate it as the return value (e.g.,
2055 \fBApp.new\fP).  This object is called app object.  If app object
2056 defines \fBon_req\fP method, it is called with \fI\%Nghttpx::Env\fP
2057 object on request hook.  Similarly, if app object defines \fBon_resp\fP
2058 method, it is called with \fI\%Nghttpx::Env\fP object on response
2059 hook.  For each method invocation, user can can access
2060 \fI\%Nghttpx::Request\fP and \fI\%Nghttpx::Response\fP objects
2061 via \fI\%Nghttpx::Env#req\fP and \fI\%Nghttpx::Env#resp\fP
2062 respectively.
2063 .INDENT 0.0
2064 .TP
2065 .B Nghttpx::REQUEST_PHASE
2066 Constant to represent request phase.
2067 .UNINDENT
2068 .INDENT 0.0
2069 .TP
2070 .B Nghttpx::RESPONSE_PHASE
2071 Constant to represent response phase.
2072 .UNINDENT
2073 .INDENT 0.0
2074 .TP
2075 .B class Nghttpx::Env
2076 Object to represent current request specific context.
2077 .INDENT 7.0
2078 .TP
2079 .B attribute [R] req
2080 Return \fI\%Request\fP object.
2081 .UNINDENT
2082 .INDENT 7.0
2083 .TP
2084 .B attribute [R] resp
2085 Return \fI\%Response\fP object.
2086 .UNINDENT
2087 .INDENT 7.0
2088 .TP
2089 .B attribute [R] ctx
2090 Return Ruby hash object.  It persists until request finishes.
2091 So values set in request phase hook can be retrieved in
2092 response phase hook.
2093 .UNINDENT
2094 .INDENT 7.0
2095 .TP
2096 .B attribute [R] phase
2097 Return the current phase.
2098 .UNINDENT
2099 .INDENT 7.0
2100 .TP
2101 .B attribute [R] remote_addr
2102 Return IP address of a remote client.  If connection is made
2103 via UNIX domain socket, this returns the string "localhost".
2104 .UNINDENT
2105 .INDENT 7.0
2106 .TP
2107 .B attribute [R] server_addr
2108 Return address of server that accepted the connection.  This
2109 is a string which specified in \fI\%\-\-frontend\fP option,
2110 excluding port number, and not a resolved IP address.  For
2111 UNIX domain socket, this is a path to UNIX domain socket.
2112 .UNINDENT
2113 .INDENT 7.0
2114 .TP
2115 .B attribute [R] server_port
2116 Return port number of the server frontend which accepted the
2117 connection from client.
2118 .UNINDENT
2119 .INDENT 7.0
2120 .TP
2121 .B attribute [R] tls_used
2122 Return true if TLS is used on the connection.
2123 .UNINDENT
2124 .INDENT 7.0
2125 .TP
2126 .B attribute [R] tls_sni
2127 Return the TLS SNI value which client sent in this connection.
2128 .UNINDENT
2129 .INDENT 7.0
2130 .TP
2131 .B attribute [R] tls_client_fingerprint_sha256
2132 Return the SHA\-256 fingerprint of a client certificate.
2133 .UNINDENT
2134 .INDENT 7.0
2135 .TP
2136 .B attribute [R] tls_client_fingerprint_sha1
2137 Return the SHA\-1 fingerprint of a client certificate.
2138 .UNINDENT
2139 .INDENT 7.0
2140 .TP
2141 .B attribute [R] tls_client_issuer_name
2142 Return the issuer name of a client certificate.
2143 .UNINDENT
2144 .INDENT 7.0
2145 .TP
2146 .B attribute [R] tls_client_subject_name
2147 Return the subject name of a client certificate.
2148 .UNINDENT
2149 .INDENT 7.0
2150 .TP
2151 .B attribute [R] tls_client_serial
2152 Return the serial number of a client certificate.
2153 .UNINDENT
2154 .INDENT 7.0
2155 .TP
2156 .B attribute [R] tls_client_not_before
2157 Return the start date of a client certificate in seconds since
2158 the epoch.
2159 .UNINDENT
2160 .INDENT 7.0
2161 .TP
2162 .B attribute [R] tls_client_not_after
2163 Return the end date of a client certificate in seconds since
2164 the epoch.
2165 .UNINDENT
2166 .INDENT 7.0
2167 .TP
2168 .B attribute [R] tls_cipher
2169 Return a TLS cipher negotiated in this connection.
2170 .UNINDENT
2171 .INDENT 7.0
2172 .TP
2173 .B attribute [R] tls_protocol
2174 Return a TLS protocol version negotiated in this connection.
2175 .UNINDENT
2176 .INDENT 7.0
2177 .TP
2178 .B attribute [R] tls_session_id
2179 Return a session ID for this connection in hex string.
2180 .UNINDENT
2181 .INDENT 7.0
2182 .TP
2183 .B attribute [R] tls_session_reused
2184 Return true if, and only if a SSL/TLS session is reused.
2185 .UNINDENT
2186 .INDENT 7.0
2187 .TP
2188 .B attribute [R] alpn
2189 Return ALPN identifier negotiated in this connection.
2190 .UNINDENT
2191 .INDENT 7.0
2192 .TP
2193 .B attribute [R] tls_handshake_finished
2194 Return true if SSL/TLS handshake has finished.  If it returns
2195 false in the request phase hook, the request is received in
2196 TLSv1.3 early data (0\-RTT) and might be vulnerable to the
2197 replay attack.  nghttpx will send Early\-Data header field to
2198 backend servers to indicate this.
2199 .UNINDENT
2200 .UNINDENT
2201 .INDENT 0.0
2202 .TP
2203 .B class Nghttpx::Request
2204 Object to represent request from client.  The modification to
2205 Request object is allowed only in request phase hook.
2206 .INDENT 7.0
2207 .TP
2208 .B attribute [R] http_version_major
2209 Return HTTP major version.
2210 .UNINDENT
2211 .INDENT 7.0
2212 .TP
2213 .B attribute [R] http_version_minor
2214 Return HTTP minor version.
2215 .UNINDENT
2216 .INDENT 7.0
2217 .TP
2218 .B attribute [R/W] method
2219 HTTP method.  On assignment, copy of given value is assigned.
2220 We don\(aqt accept arbitrary method name.  We will document them
2221 later, but well known methods, like GET, PUT and POST, are all
2222 supported.
2223 .UNINDENT
2224 .INDENT 7.0
2225 .TP
2226 .B attribute [R/W] authority
2227 Authority (i.e., example.org), including optional port
2228 component .  On assignment, copy of given value is assigned.
2229 .UNINDENT
2230 .INDENT 7.0
2231 .TP
2232 .B attribute [R/W] scheme
2233 Scheme (i.e., http, https).  On assignment, copy of given
2234 value is assigned.
2235 .UNINDENT
2236 .INDENT 7.0
2237 .TP
2238 .B attribute [R/W] path
2239 Request path, including query component (i.e., /index.html).
2240 On assignment, copy of given value is assigned.  The path does
2241 not include authority component of URI.  This may include
2242 query component.  nghttpx makes certain normalization for
2243 path.  It decodes percent\-encoding for unreserved characters
2244 (see \fI\%https://tools.ietf.org/html/rfc3986#section\-2.3\fP), and
2245 resolves ".." and ".".  But it may leave characters which
2246 should be percent\-encoded as is. So be careful when comparing
2247 path against desired string.
2248 .UNINDENT
2249 .INDENT 7.0
2250 .TP
2251 .B attribute [R] headers
2252 Return Ruby hash containing copy of request header fields.
2253 Changing values in returned hash does not change request
2254 header fields actually used in request processing.  Use
2255 \fI\%Nghttpx::Request#add_header\fP or
2256 \fI\%Nghttpx::Request#set_header\fP to change request
2257 header fields.
2258 .UNINDENT
2259 .INDENT 7.0
2260 .TP
2261 .B add_header(key, value)
2262 Add header entry associated with key.  The value can be single
2263 string or array of string.  It does not replace any existing
2264 values associated with key.
2265 .UNINDENT
2266 .INDENT 7.0
2267 .TP
2268 .B set_header(key, value)
2269 Set header entry associated with key.  The value can be single
2270 string or array of string.  It replaces any existing values
2271 associated with key.
2272 .UNINDENT
2273 .INDENT 7.0
2274 .TP
2275 .B clear_headers()
2276 Clear all existing request header fields.
2277 .UNINDENT
2278 .INDENT 7.0
2279 .TP
2280 .B push(uri)
2281 Initiate to push resource identified by \fIuri\fP\&.  Only HTTP/2
2282 protocol supports this feature.  For the other protocols, this
2283 method is noop.  \fIuri\fP can be absolute URI, absolute path or
2284 relative path to the current request.  For absolute or
2285 relative path, scheme and authority are inherited from the
2286 current request.  Currently, method is always GET.  nghttpx
2287 will issue request to backend servers to fulfill this request.
2288 The request and response phase hooks will be called for pushed
2289 resource as well.
2290 .UNINDENT
2291 .UNINDENT
2292 .INDENT 0.0
2293 .TP
2294 .B class Nghttpx::Response
2295 Object to represent response from backend server.
2296 .INDENT 7.0
2297 .TP
2298 .B attribute [R] http_version_major
2299 Return HTTP major version.
2300 .UNINDENT
2301 .INDENT 7.0
2302 .TP
2303 .B attribute [R] http_version_minor
2304 Return HTTP minor version.
2305 .UNINDENT
2306 .INDENT 7.0
2307 .TP
2308 .B attribute [R/W] status
2309 HTTP status code.  It must be in the range [200, 999],
2310 inclusive.  The non\-final status code is not supported in
2311 mruby scripting at the moment.
2312 .UNINDENT
2313 .INDENT 7.0
2314 .TP
2315 .B attribute [R] headers
2316 Return Ruby hash containing copy of response header fields.
2317 Changing values in returned hash does not change response
2318 header fields actually used in response processing.  Use
2319 \fI\%Nghttpx::Response#add_header\fP or
2320 \fI\%Nghttpx::Response#set_header\fP to change response
2321 header fields.
2322 .UNINDENT
2323 .INDENT 7.0
2324 .TP
2325 .B add_header(key, value)
2326 Add header entry associated with key.  The value can be single
2327 string or array of string.  It does not replace any existing
2328 values associated with key.
2329 .UNINDENT
2330 .INDENT 7.0
2331 .TP
2332 .B set_header(key, value)
2333 Set header entry associated with key.  The value can be single
2334 string or array of string.  It replaces any existing values
2335 associated with key.
2336 .UNINDENT
2337 .INDENT 7.0
2338 .TP
2339 .B clear_headers()
2340 Clear all existing response header fields.
2341 .UNINDENT
2342 .INDENT 7.0
2343 .TP
2344 .B return(body)
2345 Return custom response \fIbody\fP to a client.  When this method
2346 is called in request phase hook, the request is not forwarded
2347 to the backend, and response phase hook for this request will
2348 not be invoked.  When this method is called in response phase
2349 hook, response from backend server is canceled and discarded.
2350 The status code and response header fields should be set
2351 before using this method.  To set status code, use
2352 \fI\%Nghttpx::Response#status\fP\&.  If status code is not
2353 set, 200 is used.  To set response header fields,
2354 \fI\%Nghttpx::Response#add_header\fP and
2355 \fI\%Nghttpx::Response#set_header\fP\&.  When this method is
2356 invoked in response phase hook, the response headers are
2357 filled with the ones received from backend server.  To send
2358 completely custom header fields, first call
2359 \fI\%Nghttpx::Response#clear_headers\fP to erase all
2360 existing header fields, and then add required header fields.
2361 It is an error to call this method twice for a given request.
2362 .UNINDENT
2363 .INDENT 7.0
2364 .TP
2365 .B send_info(status, headers)
2366 Send non\-final (informational) response to a client.  \fIstatus\fP
2367 must be in the range [100, 199], inclusive.  \fIheaders\fP is a
2368 hash containing response header fields.  Its key must be a
2369 string, and the associated value must be either string or
2370 array of strings.  Since this is not a final response, even if
2371 this method is invoked, request is still forwarded to a
2372 backend unless \fI\%Nghttpx::Response#return\fP is called.
2373 This method can be called multiple times.  It cannot be called
2374 after \fI\%Nghttpx::Response#return\fP is called.
2375 .UNINDENT
2376 .UNINDENT
2377 .SS MRUBY EXAMPLES
2378 .sp
2379 Modify request path:
2380 .INDENT 0.0
2381 .INDENT 3.5
2382 .sp
2383 .nf
2384 .ft C
2385 class App
2386   def on_req(env)
2387     env.req.path = "/apps#{env.req.path}"
2388   end
2389 end
2390
2391 App.new
2392 .ft P
2393 .fi
2394 .UNINDENT
2395 .UNINDENT
2396 .sp
2397 Don\(aqt forget to instantiate and evaluate object at the last line.
2398 .sp
2399 Restrict permission of viewing a content to a specific client
2400 addresses:
2401 .INDENT 0.0
2402 .INDENT 3.5
2403 .sp
2404 .nf
2405 .ft C
2406 class App
2407   def on_req(env)
2408     allowed_clients = ["127.0.0.1", "::1"]
2409
2410     if env.req.path.start_with?("/log/") &&
2411        !allowed_clients.include?(env.remote_addr) then
2412       env.resp.status = 404
2413       env.resp.return "permission denied"
2414     end
2415   end
2416 end
2417
2418 App.new
2419 .ft P
2420 .fi
2421 .UNINDENT
2422 .UNINDENT
2423 .SH API ENDPOINTS
2424 .sp
2425 nghttpx exposes API endpoints to manipulate it via HTTP based API.  By
2426 default, API endpoint is disabled.  To enable it, add a dedicated
2427 frontend for API using \fI\%\-\-frontend\fP option with "api"
2428 parameter.  All requests which come from this frontend address, will
2429 be treated as API request.
2430 .sp
2431 The response is normally JSON dictionary, and at least includes the
2432 following keys:
2433 .INDENT 0.0
2434 .TP
2435 .B status
2436 The status of the request processing.  The following values are
2437 defined:
2438 .INDENT 7.0
2439 .TP
2440 .B Success
2441 The request was successful.
2442 .TP
2443 .B Failure
2444 The request was failed.  No change has been made.
2445 .UNINDENT
2446 .TP
2447 .B code
2448 HTTP status code
2449 .UNINDENT
2450 .sp
2451 Additionally, depending on the API endpoint, \fBdata\fP key may be
2452 present, and its value contains the API endpoint specific data.
2453 .sp
2454 We wrote "normally", since nghttpx may return ordinal HTML response in
2455 some cases where the error has occurred before reaching API endpoint
2456 (e.g., header field is too large).
2457 .sp
2458 The following section describes available API endpoints.
2459 .SS POST /api/v1beta1/backendconfig
2460 .sp
2461 This API replaces the current backend server settings with the
2462 requested ones.  The request method should be POST, but PUT is also
2463 acceptable.  The request body must be nghttpx configuration file
2464 format.  For configuration file format, see \fI\%FILES\fP section.  The
2465 line separator inside the request body must be single LF (0x0A).
2466 Currently, only \fI\%backend\fP option is parsed, the
2467 others are simply ignored.  The semantics of this API is replace the
2468 current backend with the backend options in request body.  Describe
2469 the desired set of backend severs, and nghttpx makes it happen.  If
2470 there is no \fI\%backend\fP option is found in request
2471 body, the current set of backend is replaced with the \fI\%backend\fP option\(aqs default value, which is \fB127.0.0.1,80\fP\&.
2472 .sp
2473 The replacement is done instantly without breaking existing
2474 connections or requests.  It also avoids any process creation as is
2475 the case with hot swapping with signals.
2476 .sp
2477 The one limitation is that only numeric IP address is allowed in
2478 \fI\%backend\fP in request body unless "dns" parameter
2479 is used while non numeric hostname is allowed in command\-line or
2480 configuration file is read using \fI\%\-\-conf\fP\&.
2481 .SS GET /api/v1beta1/configrevision
2482 .sp
2483 This API returns configuration revision of the current nghttpx.  The
2484 configuration revision is opaque string, and it changes after each
2485 reloading by SIGHUP.  With this API, an external application knows
2486 that whether nghttpx has finished reloading its configuration by
2487 comparing the configuration revisions between before and after
2488 reloading.  It is recommended to disable persistent (keep\-alive)
2489 connection for this purpose in order to avoid to send a request using
2490 the reused connection which may bound to an old process.
2491 .sp
2492 This API returns response including \fBdata\fP key.  Its value is JSON
2493 object, and it contains at least the following key:
2494 .INDENT 0.0
2495 .TP
2496 .B configRevision
2497 The configuration revision of the current nghttpx
2498 .UNINDENT
2499 .SH SEE ALSO
2500 .sp
2501 \fBnghttp(1)\fP, \fBnghttpd(1)\fP, \fBh2load(1)\fP
2502 .SH AUTHOR
2503 Tatsuhiro Tsujikawa
2504 .SH COPYRIGHT
2505 2012, 2015, 2016, Tatsuhiro Tsujikawa
2506 .\" Generated by docutils manpage writer.
2507 .