tizen 2.4 release
[external/nghttp2.git] / doc / nghttpx.1.rst
1
2 nghttpx(1)
3 ==========
4
5 SYNOPSIS
6 --------
7
8 **nghttpx** [OPTIONS]... [<PRIVATE_KEY> <CERT>]
9
10 DESCRIPTION
11 -----------
12
13 A reverse proxy for HTTP/2, HTTP/1 and SPDY.
14
15 .. describe:: <PRIVATE_KEY>
16
17     
18     Set path  to server's private key.   Required unless :option:`-p`\,
19     :option:`--client` or :option:`\--frontend-no-tls` are given.
20
21 .. describe:: <CERT>
22
23     Set path  to server's certificate.  Required  unless :option:`-p`\,
24     :option:`--client` or :option:`\--frontend-no-tls` are given.
25
26
27 OPTIONS
28 -------
29
30 The options are categorized into several groups.
31
32 Connections
33 ~~~~~~~~~~~
34
35 .. option:: -b, --backend=<HOST,PORT>
36
37     Set backend host and port.  For HTTP/1 backend, multiple
38     backend addresses are accepted by repeating this option.
39     HTTP/2  backend   does  not  support   multiple  backend
40     addresses  and the  first occurrence  of this  option is
41     used.
42
43     Default: ``127.0.0.1,80``
44
45 .. option:: -f, --frontend=<HOST,PORT>
46
47     Set  frontend  host and  port.   If  <HOST> is  '\*',  it
48     assumes all addresses including both IPv4 and IPv6.
49
50     Default: ``*,3000``
51
52 .. option:: --backlog=<N>
53
54     Set listen backlog size.
55
56     Default: ``512``
57
58 .. option:: --backend-ipv4
59
60     Resolve backend hostname to IPv4 address only.
61
62 .. option:: --backend-ipv6
63
64     Resolve backend hostname to IPv6 address only.
65
66 .. option:: --backend-http-proxy-uri=<URI>
67
68     Specify      proxy       URI      in       the      form
69     http://[<USER>:<PASS>@]<PROXY>:<PORT>.    If   a   proxy
70     requires  authentication,  specify  <USER>  and  <PASS>.
71     Note that  they must be properly  percent-encoded.  This
72     proxy  is used  when the  backend connection  is HTTP/2.
73     First,  make  a CONNECT  request  to  the proxy  and  it
74     connects  to the  backend  on behalf  of nghttpx.   This
75     forms  tunnel.   After  that, nghttpx  performs  SSL/TLS
76     handshake with  the downstream through the  tunnel.  The
77     timeouts when connecting and  making CONNECT request can
78     be     specified    by     :option:`--backend-read-timeout`    and
79     :option:`--backend-write-timeout` options.
80
81
82 Performance
83 ~~~~~~~~~~~
84
85 .. option:: -n, --workers=<N>
86
87     Set the number of worker threads.
88
89     Default: ``1``
90
91 .. option:: --read-rate=<SIZE>
92
93     Set maximum  average read  rate on  frontend connection.
94     Setting 0 to this option means read rate is unlimited.
95
96     Default: ``0``
97
98 .. option:: --read-burst=<SIZE>
99
100     Set  maximum read  burst  size  on frontend  connection.
101     Setting  0  to this  option  means  read burst  size  is
102     unlimited.
103
104     Default: ``0``
105
106 .. option:: --write-rate=<SIZE>
107
108     Set maximum  average write rate on  frontend connection.
109     Setting 0 to this option means write rate is unlimited.
110
111     Default: ``0``
112
113 .. option:: --write-burst=<SIZE>
114
115     Set  maximum write  burst size  on frontend  connection.
116     Setting  0 to  this  option means  write  burst size  is
117     unlimited.
118
119     Default: ``0``
120
121 .. option:: --worker-read-rate=<SIZE>
122
123     Set maximum average read rate on frontend connection per
124     worker.  Setting  0 to  this option  means read  rate is
125     unlimited.  Not implemented yet.
126
127     Default: ``0``
128
129 .. option:: --worker-read-burst=<SIZE>
130
131     Set maximum  read burst size on  frontend connection per
132     worker.  Setting 0 to this  option means read burst size
133     is unlimited.  Not implemented yet.
134
135     Default: ``0``
136
137 .. option:: --worker-write-rate=<SIZE>
138
139     Set maximum  average write  rate on  frontend connection
140     per worker.  Setting  0 to this option  means write rate
141     is unlimited.  Not implemented yet.
142
143     Default: ``0``
144
145 .. option:: --worker-write-burst=<SIZE>
146
147     Set maximum write burst  size on frontend connection per
148     worker.  Setting 0 to this option means write burst size
149     is unlimited.  Not implemented yet.
150
151     Default: ``0``
152
153 .. option:: --worker-frontend-connections=<N>
154
155     Set maximum number  of simultaneous connections frontend
156     accepts.  Setting 0 means unlimited.
157
158     Default: ``0``
159
160 .. option:: --backend-http1-connections-per-host=<N>
161
162     Set   maximum  number   of  backend   concurrent  HTTP/1
163     connections per host.  This option is meaningful when :option:`-s`
164     option is used.  To limit  the number of connections per
165     frontend        for       default        mode,       use
166     :option:`--backend-http1-connections-per-frontend`\.
167
168     Default: ``8``
169
170 .. option:: --backend-http1-connections-per-frontend=<N>
171
172     Set   maximum  number   of  backend   concurrent  HTTP/1
173     connections per frontend.  This  option is only used for
174     default mode.   0 means unlimited.  To  limit the number
175     of connections  per host for  HTTP/2 or SPDY  proxy mode
176     (-s option), use :option:`--backend-http1-connections-per-host`\.
177
178     Default: ``0``
179
180 .. option:: --rlimit-nofile=<N>
181
182     Set maximum number of open files (RLIMIT_NOFILE) to <N>.
183     If 0 is given, nghttpx does not set the limit.
184
185     Default: ``0``
186
187 .. option:: --backend-request-buffer=<SIZE>
188
189     Set buffer size used to store backend request.
190
191     Default: ``16K``
192
193 .. option:: --backend-response-buffer=<SIZE>
194
195     Set buffer size used to store backend response.
196
197     Default: ``16K``
198
199
200 Timeout
201 ~~~~~~~
202
203 .. option:: --frontend-http2-read-timeout=<DURATION>
204
205     Specify  read  timeout  for  HTTP/2  and  SPDY  frontend
206     connection.
207
208     Default: ``180s``
209
210 .. option:: --frontend-read-timeout=<DURATION>
211
212     Specify read timeout for HTTP/1.1 frontend connection.
213
214     Default: ``180s``
215
216 .. option:: --frontend-write-timeout=<DURATION>
217
218     Specify write timeout for all frontend connections.
219
220     Default: ``30s``
221
222 .. option:: --stream-read-timeout=<DURATION>
223
224     Specify  read timeout  for HTTP/2  and SPDY  streams.  0
225     means no timeout.
226
227     Default: ``0``
228
229 .. option:: --stream-write-timeout=<DURATION>
230
231     Specify write  timeout for  HTTP/2 and SPDY  streams.  0
232     means no timeout.
233
234     Default: ``0``
235
236 .. option:: --backend-read-timeout=<DURATION>
237
238     Specify read timeout for backend connection.
239
240     Default: ``180s``
241
242 .. option:: --backend-write-timeout=<DURATION>
243
244     Specify write timeout for backend connection.
245
246     Default: ``30s``
247
248 .. option:: --backend-keep-alive-timeout=<DURATION>
249
250     Specify keep-alive timeout for backend connection.
251
252     Default: ``2s``
253
254 .. option:: --listener-disable-timeout=<DURATION>
255
256     After accepting  connection failed,  connection listener
257     is disabled  for a given  amount of time.   Specifying 0
258     disables this feature.
259
260     Default: ``0``
261
262
263 SSL/TLS
264 ~~~~~~~
265
266 .. option:: --ciphers=<SUITE>
267
268     Set allowed  cipher list.  The  format of the  string is
269     described in OpenSSL ciphers(1).
270
271 .. option:: -k, --insecure
272
273     Don't  verify   backend  server's  certificate   if  :option:`-p`\,
274     :option:`--client`    or    :option:`\--http2-bridge`     are    given    and
275     :option:`--backend-no-tls` is not given.
276
277 .. option:: --cacert=<PATH>
278
279     Set path to trusted CA  certificate file if :option:`-p`\, :option:`--client`
280     or :option:`--http2-bridge` are given  and :option:`\--backend-no-tls` is not
281     given.  The file must be  in PEM format.  It can contain
282     multiple  certificates.    If  the  linked   OpenSSL  is
283     configured to  load system  wide certificates,  they are
284     loaded at startup regardless of this option.
285
286 .. option:: --private-key-passwd-file=<PATH>
287
288     Path  to file  that contains  password for  the server's
289     private key.   If none is  given and the private  key is
290     password protected it'll be requested interactively.
291
292 .. option:: --subcert=<KEYPATH>:<CERTPATH>
293
294     Specify  additional certificate  and  private key  file.
295     nghttpx will  choose certificates based on  the hostname
296     indicated  by  client  using TLS  SNI  extension.   This
297     option can be used multiple times.
298
299 .. option:: --backend-tls-sni-field=<HOST>
300
301     Explicitly  set the  content of  the TLS  SNI extension.
302     This will default to the backend HOST name.
303
304 .. option:: --dh-param-file=<PATH>
305
306     Path to file that contains  DH parameters in PEM format.
307     Without  this   option,  DHE   cipher  suites   are  not
308     available.
309
310 .. option:: --npn-list=<LIST>
311
312     Comma delimited list of  ALPN protocol identifier sorted
313     in the  order of preference.  That  means most desirable
314     protocol comes  first.  This  is used  in both  ALPN and
315     NPN.  The parameter must be  delimited by a single comma
316     only  and any  white spaces  are  treated as  a part  of
317     protocol string.
318
319     Default: ``h2-16,h2-14,spdy/3.1,http/1.1``
320
321 .. option:: --verify-client
322
323     Require and verify client certificate.
324
325 .. option:: --verify-client-cacert=<PATH>
326
327     Path  to file  that contains  CA certificates  to verify
328     client certificate.  The file must be in PEM format.  It
329     can contain multiple certificates.
330
331 .. option:: --client-private-key-file=<PATH>
332
333     Path to  file that contains  client private key  used in
334     backend client authentication.
335
336 .. option:: --client-cert-file=<PATH>
337
338     Path to  file that  contains client certificate  used in
339     backend client authentication.
340
341 .. option:: --tls-proto-list=<LIST>
342
343     Comma delimited list of  SSL/TLS protocol to be enabled.
344     The following protocols  are available: TLSv1.2, TLSv1.1
345     and   TLSv1.0.    The   name   matching   is   done   in
346     case-insensitive   manner.    The  parameter   must   be
347     delimited by  a single comma  only and any  white spaces
348     are treated as a part of protocol string.
349
350     Default: ``TLSv1.2,TLSv1.1``
351
352 .. option:: --tls-ticket-key-file=<PATH>
353
354     Path  to file  that  contains 48  bytes  random data  to
355     construct TLS  session ticket parameters.   This options
356     can  be  used  repeatedly  to  specify  multiple  ticket
357     parameters.  If several files  are given, only the first
358     key is used to encrypt  TLS session tickets.  Other keys
359     are accepted  but server  will issue new  session ticket
360     with  first  key.   This allows  session  key  rotation.
361     Please   note  that   key   rotation   does  not   occur
362     automatically.   User should  rearrange files  or change
363     options  values  and  restart  nghttpx  gracefully.   If
364     opening or reading given file fails, all loaded keys are
365     discarded and it is treated as if none of this option is
366     given.  If this option is not given or an error occurred
367     while  opening  or  reading  a file,  key  is  generated
368     automatically and  renewed every 12hrs.  At  most 2 keys
369     are stored in memory.
370
371 .. option:: --tls-ctx-per-worker
372
373     Create OpenSSL's SSL_CTX per worker, so that no internal
374     locking is required.  This  may improve scalability with
375     multi  threaded   configuration.   If  this   option  is
376     enabled, session ID is  no longer shared accross SSL_CTX
377     objects, which means session  ID generated by one worker
378     is not acceptable by another worker.  On the other hand,
379     session ticket key is shared across all worker threads.
380
381
382 HTTP/2 and SPDY
383 ~~~~~~~~~~~~~~~
384
385 .. option:: -c, --http2-max-concurrent-streams=<N>
386
387     Set the maximum number of  the concurrent streams in one
388     HTTP/2 and SPDY session.
389
390     Default: ``100``
391
392 .. option:: --frontend-http2-window-bits=<N>
393
394     Sets the  per-stream initial window size  of HTTP/2 SPDY
395     frontend connection.  For HTTP/2,  the size is 2\*\*<N>-1.
396     For SPDY, the size is 2\*\*<N>.
397
398     Default: ``16``
399
400 .. option:: --frontend-http2-connection-window-bits=<N>
401
402     Sets the  per-connection window size of  HTTP/2 and SPDY
403     frontend   connection.    For   HTTP/2,  the   size   is
404     2**<N>-1. For SPDY, the size is 2\*\*<N>.
405
406     Default: ``16``
407
408 .. option:: --frontend-no-tls
409
410     Disable SSL/TLS on frontend connections.
411
412 .. option:: --backend-http2-window-bits=<N>
413
414     Sets  the   initial  window   size  of   HTTP/2  backend
415     connection to 2\*\*<N>-1.
416
417     Default: ``16``
418
419 .. option:: --backend-http2-connection-window-bits=<N>
420
421     Sets the  per-connection window  size of  HTTP/2 backend
422     connection to 2\*\*<N>-1.
423
424     Default: ``16``
425
426 .. option:: --backend-no-tls
427
428     Disable SSL/TLS on backend connections.
429
430 .. option:: --http2-no-cookie-crumbling
431
432     Don't crumble cookie header field.
433
434 .. option:: --padding=<N>
435
436     Add  at most  <N> bytes  to  a HTTP/2  frame payload  as
437     padding.  Specify 0 to  disable padding.  This option is
438     meant for debugging purpose  and not intended to enhance
439     protocol security.
440
441 .. option:: --no-server-push
442
443     Disable  HTTP/2  server  push.    Server  push  is  only
444     supported  by default  mode and  HTTP/2 frontend.   SPDY
445     frontend does not support server push.
446
447
448 Mode
449 ~~~~
450
451 .. describe:: (default mode)
452
453     
454     Accept  HTTP/2,  SPDY  and HTTP/1.1  over  SSL/TLS.   If
455     :option:`--frontend-no-tls` is  used, accept HTTP/2  and HTTP/1.1.
456     The  incoming HTTP/1.1  connection  can  be upgraded  to
457     HTTP/2  through  HTTP  Upgrade.   The  protocol  to  the
458     backend is HTTP/1.1.
459
460 .. option:: -s, --http2-proxy
461
462     Like default mode, but enable secure proxy mode.
463
464 .. option:: --http2-bridge
465
466     Like default  mode, but communicate with  the backend in
467     HTTP/2 over SSL/TLS.  Thus  the incoming all connections
468     are converted  to HTTP/2  connection and relayed  to the
469     backend.  See :option:`--backend-http-proxy-uri` option if you are
470     behind  the proxy  and want  to connect  to the  outside
471     HTTP/2 proxy.
472
473 .. option:: --client
474
475     Accept  HTTP/2   and  HTTP/1.1  without   SSL/TLS.   The
476     incoming HTTP/1.1  connection can be upgraded  to HTTP/2
477     connection through  HTTP Upgrade.   The protocol  to the
478     backend is HTTP/2.   To use nghttpx as  a forward proxy,
479     use :option:`-p` option instead.
480
481 .. option:: -p, --client-proxy
482
483     Like :option:`--client`  option, but it also  requires the request
484     path from frontend must be an absolute URI, suitable for
485     use as a forward proxy.
486
487
488 Logging
489 ~~~~~~~
490
491 .. option:: -L, --log-level=<LEVEL>
492
493     Set the severity  level of log output.   <LEVEL> must be
494     one of INFO, NOTICE, WARN, ERROR and FATAL.
495
496     Default: ``NOTICE``
497
498 .. option:: --accesslog-file=<PATH>
499
500     Set path to write access log.  To reopen file, send USR1
501     signal to nghttpx.
502
503 .. option:: --accesslog-syslog
504
505     Send  access log  to syslog.   If this  option is  used,
506     :option:`--accesslog-file` option is ignored.
507
508 .. option:: --accesslog-format=<FORMAT>
509
510     Specify  format  string  for access  log.   The  default
511     format is combined format.   The following variables are
512     available:
513
514     * $remote_addr: client IP address.
515     * $time_local: local time in Common Log format.
516     * $time_iso8601: local time in ISO 8601 format.
517     * $request: HTTP request line.
518     * $status: HTTP response status code.
519     * $body_bytes_sent: the  number of bytes sent  to client
520       as response body.
521     * $http_<VAR>: value of HTTP  request header <VAR> where
522       '_' in <VAR> is replaced with '-'.
523     * $remote_port: client  port.
524     * $server_port: server port.
525     * $request_time: request processing time in seconds with
526       milliseconds resolution.
527     * $pid: PID of the running process.
528     * $alpn: ALPN identifier of the protocol which generates
529       the response.   For HTTP/1,  ALPN is  always http/1.1,
530       regardless of minor version.
531
532
533     Default: ``$remote_addr - - [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent"``
534
535 .. option:: --errorlog-file=<PATH>
536
537     Set path to write error  log.  To reopen file, send USR1
538     signal to nghttpx.
539
540     Default: ``/dev/stderr``
541
542 .. option:: --errorlog-syslog
543
544     Send  error log  to  syslog.  If  this  option is  used,
545     :option:`--errorlog-file` option is ignored.
546
547 .. option:: --syslog-facility=<FACILITY>
548
549     Set syslog facility to <FACILITY>.
550
551     Default: ``daemon``
552
553
554 HTTP
555 ~~~~
556
557 .. option:: --add-x-forwarded-for
558
559     Append  X-Forwarded-For header  field to  the downstream
560     request.
561
562 .. option:: --strip-incoming-x-forwarded-for
563
564     Strip X-Forwarded-For  header field from  inbound client
565     requests.
566
567 .. option:: --no-via
568
569     Don't append to  Via header field.  If  Via header field
570     is received, it is left unaltered.
571
572 .. option:: --no-location-rewrite
573
574     Don't rewrite  location header field  on :option:`--http2-bridge`\,
575     :option:`--client`  and  default   mode.   For  :option:`\--http2-proxy`  and
576     :option:`--client-proxy` mode,  location header field will  not be
577     altered regardless of this option.
578
579 .. option:: --no-host-rewrite
580
581     Don't  rewrite  host  and :authority  header  fields  on
582     :option:`--http2-bridge`\,   :option:`--client`   and  default   mode.    For
583     :option:`--http2-proxy`  and  :option:`\--client-proxy` mode,  these  headers
584     will not be altered regardless of this option.
585
586 .. option:: --altsvc=<PROTOID,PORT[,HOST,[ORIGIN]]>
587
588     Specify   protocol  ID,   port,  host   and  origin   of
589     alternative service.  <HOST>  and <ORIGIN> are optional.
590     They are  advertised in  alt-svc header field  or HTTP/2
591     ALTSVC frame.  This option can be used multiple times to
592     specify   multiple   alternative   services.    Example:
593     :option:`--altsvc`\=h2,443
594
595 .. option:: --add-response-header=<HEADER>
596
597     Specify  additional  header  field to  add  to  response
598     header set.   This option just appends  header field and
599     won't replace anything already  set.  This option can be
600     used several  times to  specify multiple  header fields.
601     Example: :option:`--add-response-header`\="foo: bar"
602
603
604 Debug
605 ~~~~~
606
607 .. option:: --frontend-http2-dump-request-header=<PATH>
608
609     Dumps request headers received by HTTP/2 frontend to the
610     file denoted  in <PATH>.  The  output is done  in HTTP/1
611     header field format and each header block is followed by
612     an empty line.  This option  is not thread safe and MUST
613     NOT be used with option :option:`-n`\<N>, where <N> >= 2.
614
615 .. option:: --frontend-http2-dump-response-header=<PATH>
616
617     Dumps response headers sent  from HTTP/2 frontend to the
618     file denoted  in <PATH>.  The  output is done  in HTTP/1
619     header field format and each header block is followed by
620     an empty line.  This option  is not thread safe and MUST
621     NOT be used with option :option:`-n`\<N>, where <N> >= 2.
622
623 .. option:: -o, --frontend-frame-debug
624
625     Print HTTP/2 frames in  frontend to stderr.  This option
626     is  not thread  safe and  MUST NOT  be used  with option
627     :option:`-n`\=N, where N >= 2.
628
629
630 Process
631 ~~~~~~~
632
633 .. option:: -D, --daemon
634
635     Run in a background.  If :option:`-D` is used, the current working
636     directory is changed to '*/*'.
637
638 .. option:: --pid-file=<PATH>
639
640     Set path to save PID of this program.
641
642 .. option:: --user=<USER>
643
644     Run this program as <USER>.   This option is intended to
645     be used to drop root privileges.
646
647
648 Misc
649 ~~~~
650
651 .. option:: --conf=<PATH>
652
653     Load configuration from <PATH>.
654
655     Default: ``/etc/nghttpx/nghttpx.conf``
656
657 .. option:: -v, --version
658
659     Print version and exit.
660
661 .. option:: -h, --help
662
663     Print this help and exit.
664
665
666 The <SIZE> argument is an integer and an optional unit (e.g., 10K is
667 10 * 1024).  Units are K, M and G (powers of 1024).
668
669 The <DURATION> argument is an integer and an optional unit (e.g., 1s
670 is 1 second and 500ms is 500  milliseconds).  Units are s or ms.  If
671 a unit is omitted, a second is used as unit.
672
673 FILES
674 -----
675
676 */etc/nghttpx/nghttpx.conf*
677   The default configuration file path nghttpx searches at startup.
678   The configuration file path can be changed using :option:`--conf`
679   option.
680
681   Those lines which are staring ``#`` are treated as comment.
682
683   The option name in the configuration file is the long command-line
684   option name with leading ``--`` stripped (e.g., ``frontend``).  Put
685   ``=`` between option name and value.  Don't put extra leading or
686   trailing spaces.
687
688   The options which do not take argument in the command-line *take*
689   argument in the configuration file.  Specify ``yes`` as an argument
690   (e.g., ``http2-proxy=yes``).  If other string is given, it is
691   ignored.
692
693   To specify private key and certificate file which are given as
694   positional arguments in commnad-line, use ``private-key-file`` and
695   ``certificate-file``.
696
697   :option:`--conf` option cannot be used in the configuration file and
698   will be ignored if specified.
699
700 SIGNALS
701 -------
702
703 SIGQUIT
704   Shutdown gracefully.  First accept pending connections and stop
705   accepting connection.  After all connections are handled, nghttpx
706   exits.
707
708 SIGUSR1
709   Reopen log files.
710
711 SIGUSR2
712   Fork and execute nghttpx.  It will execute the binary in the same
713   path with same command-line arguments and environment variables.
714   After new process comes up, sending SIGQUIT to the original process
715   to perform hot swapping.
716
717 SERVER PUSH
718 -----------
719
720 nghttpx supports HTTP/2 server push in default mode.  nghttpx looks
721 for Link header field (`RFC 5988
722 <http://tools.ietf.org/html/rfc5988>`_) in response headers for
723 backend server and extracts URI-reference with parameter
724 ``rel=preload`` (see `preload
725 <http://w3c.github.io/preload/#interoperability-with-http-link-header>`_)
726 and pushes those URIs to the frontend client. Here is a sample Link
727 header field to initiate server push:
728
729 .. code-block:: http
730
731   Link: </fonts/font.woff>; rel=preload
732   Link: </css/theme.css>; rel=preload
733
734 Currently, the following restrictions are applied for server push:
735
736 1. URI-reference must not contain authority.  If it exists, it is not
737    pushed.  ``/fonts/font.woff`` and ``css/theme.css`` are eligible to
738    be pushed.  ``https://example.org/fonts/font.woff`` and
739    ``//example.org/css/theme.css`` are not.
740
741 2. The associated stream must have method "GET" or "POST".  The
742    associated stream's status code must be 200.
743
744 These limitations may be loosened in the future release.
745
746 SEE ALSO
747 --------
748
749 :manpage:`nghttp(1)`, :manpage:`nghttpd(1)`, :manpage:`h2load(1)`