8 **nghttpx** [OPTIONS]... [<PRIVATE_KEY> <CERT>]
13 A reverse proxy for HTTP/2, HTTP/1 and SPDY.
15 .. describe:: <PRIVATE_KEY>
18 Set path to server's private key. Required unless :option:`-p`\,
19 :option:`--client` or :option:`\--frontend-no-tls` are given.
23 Set path to server's certificate. Required unless :option:`-p`\,
24 :option:`--client` or :option:`\--frontend-no-tls` are given.
30 The options are categorized into several groups.
35 .. option:: -b, --backend=<HOST,PORT>
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
43 Default: ``127.0.0.1,80``
45 .. option:: -f, --frontend=<HOST,PORT>
47 Set frontend host and port. If <HOST> is '\*', it
48 assumes all addresses including both IPv4 and IPv6.
52 .. option:: --backlog=<N>
54 Set listen backlog size.
58 .. option:: --backend-ipv4
60 Resolve backend hostname to IPv4 address only.
62 .. option:: --backend-ipv6
64 Resolve backend hostname to IPv6 address only.
66 .. option:: --backend-http-proxy-uri=<URI>
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.
85 .. option:: -n, --workers=<N>
87 Set the number of worker threads.
91 .. option:: --read-rate=<SIZE>
93 Set maximum average read rate on frontend connection.
94 Setting 0 to this option means read rate is unlimited.
98 .. option:: --read-burst=<SIZE>
100 Set maximum read burst size on frontend connection.
101 Setting 0 to this option means read burst size is
106 .. option:: --write-rate=<SIZE>
108 Set maximum average write rate on frontend connection.
109 Setting 0 to this option means write rate is unlimited.
113 .. option:: --write-burst=<SIZE>
115 Set maximum write burst size on frontend connection.
116 Setting 0 to this option means write burst size is
121 .. option:: --worker-read-rate=<SIZE>
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.
129 .. option:: --worker-read-burst=<SIZE>
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.
137 .. option:: --worker-write-rate=<SIZE>
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.
145 .. option:: --worker-write-burst=<SIZE>
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.
153 .. option:: --worker-frontend-connections=<N>
155 Set maximum number of simultaneous connections frontend
156 accepts. Setting 0 means unlimited.
160 .. option:: --backend-http1-connections-per-host=<N>
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`\.
170 .. option:: --backend-http1-connections-per-frontend=<N>
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`\.
180 .. option:: --rlimit-nofile=<N>
182 Set maximum number of open files (RLIMIT_NOFILE) to <N>.
183 If 0 is given, nghttpx does not set the limit.
187 .. option:: --backend-request-buffer=<SIZE>
189 Set buffer size used to store backend request.
193 .. option:: --backend-response-buffer=<SIZE>
195 Set buffer size used to store backend response.
203 .. option:: --frontend-http2-read-timeout=<DURATION>
205 Specify read timeout for HTTP/2 and SPDY frontend
210 .. option:: --frontend-read-timeout=<DURATION>
212 Specify read timeout for HTTP/1.1 frontend connection.
216 .. option:: --frontend-write-timeout=<DURATION>
218 Specify write timeout for all frontend connections.
222 .. option:: --stream-read-timeout=<DURATION>
224 Specify read timeout for HTTP/2 and SPDY streams. 0
229 .. option:: --stream-write-timeout=<DURATION>
231 Specify write timeout for HTTP/2 and SPDY streams. 0
236 .. option:: --backend-read-timeout=<DURATION>
238 Specify read timeout for backend connection.
242 .. option:: --backend-write-timeout=<DURATION>
244 Specify write timeout for backend connection.
248 .. option:: --backend-keep-alive-timeout=<DURATION>
250 Specify keep-alive timeout for backend connection.
254 .. option:: --listener-disable-timeout=<DURATION>
256 After accepting connection failed, connection listener
257 is disabled for a given amount of time. Specifying 0
258 disables this feature.
266 .. option:: --ciphers=<SUITE>
268 Set allowed cipher list. The format of the string is
269 described in OpenSSL ciphers(1).
271 .. option:: -k, --insecure
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.
277 .. option:: --cacert=<PATH>
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.
286 .. option:: --private-key-passwd-file=<PATH>
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.
292 .. option:: --subcert=<KEYPATH>:<CERTPATH>
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.
299 .. option:: --backend-tls-sni-field=<HOST>
301 Explicitly set the content of the TLS SNI extension.
302 This will default to the backend HOST name.
304 .. option:: --dh-param-file=<PATH>
306 Path to file that contains DH parameters in PEM format.
307 Without this option, DHE cipher suites are not
310 .. option:: --npn-list=<LIST>
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
319 Default: ``h2-16,h2-14,spdy/3.1,http/1.1``
321 .. option:: --verify-client
323 Require and verify client certificate.
325 .. option:: --verify-client-cacert=<PATH>
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.
331 .. option:: --client-private-key-file=<PATH>
333 Path to file that contains client private key used in
334 backend client authentication.
336 .. option:: --client-cert-file=<PATH>
338 Path to file that contains client certificate used in
339 backend client authentication.
341 .. option:: --tls-proto-list=<LIST>
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.
350 Default: ``TLSv1.2,TLSv1.1``
352 .. option:: --tls-ticket-key-file=<PATH>
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.
371 .. option:: --tls-ctx-per-worker
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.
385 .. option:: -c, --http2-max-concurrent-streams=<N>
387 Set the maximum number of the concurrent streams in one
388 HTTP/2 and SPDY session.
392 .. option:: --frontend-http2-window-bits=<N>
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>.
400 .. option:: --frontend-http2-connection-window-bits=<N>
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>.
408 .. option:: --frontend-no-tls
410 Disable SSL/TLS on frontend connections.
412 .. option:: --backend-http2-window-bits=<N>
414 Sets the initial window size of HTTP/2 backend
415 connection to 2\*\*<N>-1.
419 .. option:: --backend-http2-connection-window-bits=<N>
421 Sets the per-connection window size of HTTP/2 backend
422 connection to 2\*\*<N>-1.
426 .. option:: --backend-no-tls
428 Disable SSL/TLS on backend connections.
430 .. option:: --http2-no-cookie-crumbling
432 Don't crumble cookie header field.
434 .. option:: --padding=<N>
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
441 .. option:: --no-server-push
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.
451 .. describe:: (default mode)
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
460 .. option:: -s, --http2-proxy
462 Like default mode, but enable secure proxy mode.
464 .. option:: --http2-bridge
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
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.
481 .. option:: -p, --client-proxy
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.
491 .. option:: -L, --log-level=<LEVEL>
493 Set the severity level of log output. <LEVEL> must be
494 one of INFO, NOTICE, WARN, ERROR and FATAL.
498 .. option:: --accesslog-file=<PATH>
500 Set path to write access log. To reopen file, send USR1
503 .. option:: --accesslog-syslog
505 Send access log to syslog. If this option is used,
506 :option:`--accesslog-file` option is ignored.
508 .. option:: --accesslog-format=<FORMAT>
510 Specify format string for access log. The default
511 format is combined format. The following variables are
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
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.
533 Default: ``$remote_addr - - [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent"``
535 .. option:: --errorlog-file=<PATH>
537 Set path to write error log. To reopen file, send USR1
540 Default: ``/dev/stderr``
542 .. option:: --errorlog-syslog
544 Send error log to syslog. If this option is used,
545 :option:`--errorlog-file` option is ignored.
547 .. option:: --syslog-facility=<FACILITY>
549 Set syslog facility to <FACILITY>.
557 .. option:: --add-x-forwarded-for
559 Append X-Forwarded-For header field to the downstream
562 .. option:: --strip-incoming-x-forwarded-for
564 Strip X-Forwarded-For header field from inbound client
569 Don't append to Via header field. If Via header field
570 is received, it is left unaltered.
572 .. option:: --no-location-rewrite
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.
579 .. option:: --no-host-rewrite
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.
586 .. option:: --altsvc=<PROTOID,PORT[,HOST,[ORIGIN]]>
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
595 .. option:: --add-response-header=<HEADER>
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"
607 .. option:: --frontend-http2-dump-request-header=<PATH>
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.
615 .. option:: --frontend-http2-dump-response-header=<PATH>
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.
623 .. option:: -o, --frontend-frame-debug
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.
633 .. option:: -D, --daemon
635 Run in a background. If :option:`-D` is used, the current working
636 directory is changed to '*/*'.
638 .. option:: --pid-file=<PATH>
640 Set path to save PID of this program.
642 .. option:: --user=<USER>
644 Run this program as <USER>. This option is intended to
645 be used to drop root privileges.
651 .. option:: --conf=<PATH>
653 Load configuration from <PATH>.
655 Default: ``/etc/nghttpx/nghttpx.conf``
657 .. option:: -v, --version
659 Print version and exit.
661 .. option:: -h, --help
663 Print this help and exit.
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).
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.
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`
681 Those lines which are staring ``#`` are treated as comment.
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
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
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``.
697 :option:`--conf` option cannot be used in the configuration file and
698 will be ignored if specified.
704 Shutdown gracefully. First accept pending connections and stop
705 accepting connection. After all connections are handled, nghttpx
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.
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:
731 Link: </fonts/font.woff>; rel=preload
732 Link: </css/theme.css>; rel=preload
734 Currently, the following restrictions are applied for server push:
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.
741 2. The associated stream must have method "GET" or "POST". The
742 associated stream's status code must be 200.
744 These limitations may be loosened in the future release.
749 :manpage:`nghttp(1)`, :manpage:`nghttpd(1)`, :manpage:`h2load(1)`