NaviServer - programmable web server
4.99  5.0

[ Main Table Of Contents | Table Of Contents | Keyword Index ]

nssock(n) 5.0.0a nssock "NaviServer Modules"

Name

nssock - Configuring HTTP socket communications

Table Of Contents

Description

This module nssock is used for the socket communication over HTTP. For the communication over HTTPS, the module nsssl is used, which shares the configuration parameters presented here and adds additional parameters.

The module nssock is typically loaded per server, e.g. for server1:

 ns_section ns/server/server1/modules {
   ns_param   nssock   nssock.so
 }
 
 ns_section ns/server/server1/module/nssock {
   ns_param port 8000
   ...
 }

This amount of configuration is sufficient for many installations, which do not want to run the server on port 80 (which requires as well root permissions for starting).

CONFIGURATION

The module nssock provides a rich set of configuration options, which are important for large installation. However, all parameters are equipped with sensible default values, such that none of these are required.

acceptsize

Maximum number of requests accepted at once (integer, defaults to the value backlog)

address

Space separated list of one or more IP addresses on which the server should listen. If no address is given it obtain the address from the hostname (either the specified hostname or the hostname reported by the OS).

backlog

Maximum number of entries for waiting listen connections (integer, default: 256)

bufsize

Maximum size in bytes (octets) for a single receive operation. The value can be specified in memory units (kB, MB, GB, KiB, MiB, GiB); (memory unit, default: 16kB)

closewait

Timeout for close on socket to drain potential garbage if no keep alive is performed. (time unit, default: 2s)

defaultserver

In a virtual server setup (when the driver module is loaded globally), this parameter is required and refers to the default server (the server, receiving all requests without host header fields unspecified or with unspecified host header fields, not mapped to a specific server)

deferaccept

TCP performance option; use TCP_FASTOPEN or TCP_DEFER_ACCEPT or SO_ACCEPTFILTER, whatever is available in your operating system to improve the performance of the initial TCP 3-way handshake. The capabilities of the operating system are determined at compile time. If you want to use TCP_FASTOPEN (introduced by Linux kernel 3.7.0), you might have to activate this option in your kernel, by using

 sudo sysctl net.ipv4.tcp_fastopen=1

(boolean, default: false)

driverthreads

Number of driver threads threads. Specifying multiple driver threads require the OS kernel to support SO_REUSEPORT and can improve the performance for high load applications slightly. (integer, default: 1)

When multiple driver threads are configured, parameter "reuseport" is automatically set to "true".

Note: When using multiple driver threads on privileged ports, one has to add "#" followed by the number of necessary bind operations to the prebind address. Otherwise, prebind will bind to the address only once, and only one driverthread can be used.

extraheaders

This parameter can be used to add extra response headers for every response sent over this driver. The extraheaders have the form for attribute/value pairs. This mechanism can be used to implement for example HTTP Strict Transport Security in nsssl, which uses the same parameter definition.

hostname

Hostname of the server, can be looked up automatically if not specified.

keepalivemaxdownloadsize

Don't allow keep-alive for downloads content larger than this size in bytes; a value of 0 means that this feature is deactivated. (memory unit, default: 0)

keepalivemaxuploadsize

Don't allow keep-alive for upload content larger than this size in bytes; a value of 0 means that this feature is deactivated. (memory unit, default: 0)

keepwait

Timeout for keep-alive. (time unit, default: 5s)

location

Provide a default for protocol://hostname[:port]. Useful for virtual servers.

maxheaders

Maximum number of header lines (integer, 128)

maxinput

Maximum size in for content loaded into the server, such as upload of files. (memory unit, default: 1MB)

maxline

Maximum size in bytes (octets) of a single header line (integer, default: 8192)

maxqueuesize

Size of the queue of accepted requests waiting for a connection thread (integer, default 1024).

maxupload

Spool uploads to tmp-files for uploads larger than this size (in memory units) in order to keep the memory footprint small. This is especially important when large uploads are allowed via maxinput. If this value is 0, this feature is deactivated. When spool-to-file is activated, the minimal size is the size of readahead (see as well spoolerthreads). (memory unit, default: 0)

nodelay

TCP Performance option; use TCP_NODELAY to disable Nagle algorithm (boolean, default: true)

port

Space separated list of one or more ports on which the server should listen. When the port is specified as 0, the module with its defined commands (such as ns_http) is loaded, but the driver will not be listening on any port. (16-bit positive integer, default: 80)

readahead

Maximum size in memory units for asynchronous read ahead operations. (memory unit, default: value of bufsize)

recvwait

Timeout for receive operations. (value with optional time unit, default: 30s)

reuseport

When the parameter is set and SO_REUSEPORT is supported by the operating system, NaviServer will allow multiple listen operations on the same port (default: false)

sendwait

Timeout for send operations. (time unit, default: 30s)

spoolerthreads

Number of spooler threads used when content larger than maxupload is received. When spoolerthreads are set to 0, the driver threads handles upload-spooling as wellto memory; (integer, default: 0)

uploadpath

Directory for uploads, defaults to the setting of ns/parameter tmpdir.

writerbufsize

Buffer size in memory units for writer threads. (memory unit, default: 8kB)

writerratelimit

Limit the rate of the data transferred via writer threads. The numeric value can be specified as KB/s (kilobytes per second) and can be refined per connection pool or per single connection (default: 0, meaning unlimited)

writersize

Use writer threads for replies above this memory amount. (memory unit, default: 1MB)

writerstreaming

Use writer threads for streaming HTML output (e.g. ns_write ...). (boolean, default: false)

writerthreads

Number of writer threads. (integer, default: 0)

All time units can be specified with and without a time unit suffix. Valid time units are "ms", "s", "m", "h", "d". If no time unit suffix is specified, seconds are assumed.

All memory sizes can be specified with and without a memory unit suffix. Valid memory units are kB, MB, GB, KiB, MiB, GiB. If no memory unit suffix is specified, bytes are assumed

EXAMPLES

For discussion and examples see admin-config.

See Also

ns_http, ns_log, ns_write, nsssl

Keywords

SO_REUSEPORT, TCP, TCP_FASTOPEN, configuration, driver, module, nssock, nsssl, pagedir, performance, prebind, redirect, tuning