tntnet.conf(7) Tntnet users guide tntnet.conf(7)
NAME
tntnet.conf - configuration-file for tntnet(8)
DESCRIPTION
Tntnet is configured in the configuration-file tntnet.conf. tntnet.conf contains configuration variables with parameters.
Each line in tntnet.conf is either empty, a comment starting with '#' or a variable with 0 or more parameters.
The variablename and parameters are spearated by whitespace. A parameter can be surrounded by quotation-marks (")or apostrophes ('). If
the parameter is marked this way, it can contain whitespace itself - even linefeeds. If the value itself needs to have the separator, the
character can be prepended by backslash, which disables the special meaning of the character itself.
Examples:
Varname value
Defines a variable with the name Varname and the value value.
Varname2 value1 value2 "This is a value with whitespace
and newline and quotationsmark: ""
Defines a variable with 3 parameters.
CONFIGURATION VARIABLES
This section describes the variables, used by Tntnet(8).
AccessLog filename
Writes a log entry for each request in a common format. This format is compatible with most log file analyze systems for http servers.
The log file has the fields:
peer-ip - username [time] "http-method query-string HTTP/major-version.minor-version" http-return-code content-size "referer" "user-agent"
The username, referer and user-agent may be '-' when the value is not available. Also the content-size can be empty in rare cases.
Example
AccessLog /var/log/tntnet/access.log
BufferSize bytes
Specifies the number of bytes sent in a single system-call. This does not limit anything in application-level. It does not affect e.g.
savepoints or exception-handling. Component-output is collected completely and then passed in chunks of BufferSize bytes to the operating
system.
The default value is 16384.
CompPath directory
CompPath specifies, where tntnet should search for webapplications. Tntnet searches first in the current directory and then in each direc-
tory, you specify here, until a library is found. You can repeat the directive as many times as desired to add more entries. If it is not
found, the next MapUrl-entry is tried.
Example
CompPath /usr/local/lib/tntnet
CompPath /usr/local/share/tntnet
Chroot directory
Does a chroot(2)-system call on startup, which locks the process into the directory at system-level.
Example
Chroot /var/tntnet
Daemon 0|1
If this flag is set to 1, Tntnet forks at startup and terminates the parent-process on successful initialization.
Dir directory
Changes the current working directory of the process on startup.
Example
Dir /var/tntnet
EnableCompression yes|no
Specifies, if Tntnet should use gzip-compression at http-level. By default Tntnet use compression. A http-client like a web browser can
send a header "Accept-Encoding", to tell Tntnet, that it would accept compressed data. Tntnet then can decide, if it use compression.
When the body is complete, Tntnet tries to compress the body. If the data can be compressed by more than 10%, Tntnet sends this compressed
data. With this flag, this feature can be turned off.
Compression slows down processing but reduces the network-load. Normally the size of html-pages can be compressed by about 70%, while Tnt-
net slows down by up to 30%.
Example
EnableCompression no
ErrorLog filename
Redirects stderr to the specified file when tntnet runs as a daemon. If ErrorLog is not set stderr is redirected to /dev/null.
Example
ErrorLog /var/log/tntnet/error.log
Group unix-group
Changes the group under which tntnet answers requests.
Example
Group tntnet-group
include filemask
Reads additional settings from the specified files. Filemask might contain glob-characters, so that multiple files might be read. The
order is not specified.
Example
include /etc/tntnet.d/*.conf
KeepAliveTimeout milliseconds
Sets the timeout for keep-alive requests.
Tntnet tries to do keep-alive-requests wherever possible. This has the effect, that tntnet can receive multiple requests within a single
tcp-connection. The connection times out after KeepAliveTimeout milliseconds. The timeout defaults to 15000ms.
Example
KeepAliveTimeout 300000
KeepAliveMax number
Sets the maximum number of request per tcp-connection. This defaults to 100.
Example
KeepAliveMax 10
Listen ip [port]
Specifies, on which address tntnet waits for connections. There can be more than one Listen-directives, in which case tntnet waits on
every address. If there is no Listen-directive tntnet listens on 0.0.0.0 port 80. ip might also be a hostname.
Example Listen 127.0.0.1 8000
ListenRetry number
On startup Tntnet calls listen on the specified port. When the systemcall returns with an error, Tntnet tries again and fails after the
specified number of attempts.
The default number is 5.
Example
ListenRetry 10
ListenBacklog number
The system-call listen(3p) needs a parameter backlog, which specifies, how many pending connections the operating-system should queue
before it starts to ignore new request. The value is configurable here.
The default value is 16
Example
ListenBacklog 64
MapUrl url component-identifier [ path-info { additional-arguments } ]
Tells tntnet, which component should be called, when it receives a http-request. url is a regular expression, which is tried against the
request-url. If it matches, the component-identifier is evaluated. component-idetifier may contain backreferences to the url. By default
the url is passed as path-info to the component, but this can be changed with a third parameter. Additional parameters can be passed to
the component and accessed through tnt::httpRequest::getArgs().
This variable can occur more than once and they are tried in the order they are found in the configurationfile, until the regular expres-
sion matches and the component does not return tnt::DECLINED. If no MapUrl-directive is found, http-error 404 (not found) is sent.
Example
# maps html-pages to components in myapp.so; e.g. /foo.html calls foo@myapp MapUrl /([^/.]+).html $1@myapp # maps jpeg-urls to myapp;
e.g. /foo.jpeg calls foo_jpg@myapp MapUrl /([^/.]+).jpeg $1_jpg@myapp # maps /foo/bar.html to bar@foo MapUrl
/([^/.]+)/([^/.].html $2@$1
Example
MapUrlMapCache size
As described in MapUrl urls are mapped to components with regular expressions. This is a quite expensive operation, while the number of
different urls used in a typical web application is small. Therefore Tntnet has a simple cache, which stores mappings to prevent the need
to process the same regular expression multiple times. The size of this cache is limited. After the size is exceeded the cache is simply
cleared. This clearing is logged with the message "clear url-map-cache". If you have a application whit many different urls and you often
see this warning-message, you might want to increase the cache.
The default value is 8192.
Example
MapUrlMapCache 32768
MaxRequestSize number
This directive limits the size of the request. After number Bytes the connection is just closed. This prevents denial-of-service-attacks
through long requests. Every request is read into memory, so it must fit into it. Bear in mind, that if you use file-upload-fields a
request might be larger than just a few bytes. The value defaults to 0, which means, that there is no limit at all.
Example
MaxRequestSize 65536
MaxRequestTime seconds
In daemon mode tntnet has a watchdog, which restarts tntnet when the maximum request time is exceeded. This happens, when a request is in a
endless loop or otherwise hangs. Restarting tntnet looses all active sessions and the currently running requests. Therefore the timeout
should be well long enough for the longes request.
The default value is 600 seconds, which is normally much longer than a http request should run. If the Timeout is set to 0, the watchdog is
deactivated.
Example
MaxRequestTime 1200
MinThreads number
Tntnet uses a dynamic pool of worker-threads, which wait for incoming requests. MinThreads specifies, how many worker threads there have to
be. This defaults to 5.
Example
MinThreads 10
MinCompressSize number
Http-compression for replies smaller than this are not compressed at all.
The default value for this is 1024.
Example
MinCompressSize 256
MaxThreads number
Tntnet uses a dynamic pool of worker-threads, which wait for incoming requests. MaxThreads limits the number of threads.
The default is 100.
Example
MaxThreads 200
PidFile filename
When run in daemon-mode, tntnet writes the process-id of the monitor-process to filename. When the monitor-process is deactivated, the pid
of the worker-process is written. This ensures, that sending a sigkill to the the stored process-id stops tntnet.
Example
PidFile /var/run/tntnet.pid
PropertyFile filename
This directive specifies the property-file, where logging is configured.
Example
PropertyFile /etc/tntnet/tntnet.property
QueueSize number
Tntnet has a request-queue, where new requests wait for service. This sets a maximum size of this queue, after wich new requests are not
accepted.
The default value is 1000.
Example
QueueSize 50
SessionTimeout seconds
This sets the number of seconds without requests after which a sesssion is erased.
The default value is 300 seconds.
Example
SessionTimeout 600
SocketReadTimeout milliseconds
A worker-thread waits for some milliseconds on incoming data. If there is no data, the job is put into a queue and another thread waits
with poll(2) on incoming data on multiple sockets. The workerthreads are freed and they can respond to other requests quickly. The
default value is 10 milliseconds, which is good for normal operation. A value of 0 results in non-blocking read. If timeout is reached,
this does not mean, that the socket is closed. A small timeout reduces contextswitches on slow connections.
Example
SocketReadTimeout 0
SocketWriteTimeout milliseconds
This defines the time, how long the workerthreads wait on write. If the timeout is exceeded, the socket is closed and the browser might
not get all data. The default value is 10000 milliseconds.
Example
SocketWriteTimeout 20000
SslCertificate file
Specifies the certificate-file for ssl-connections if not specified in SslListen
SslKey file
Specifies the certificate-key for ssl-connections if not specified in SslListen
SslListen ip [port [ssl-certificate-file [ssl-key-file] ] ]
Specifies, on which ip and port tntnet waits for incoming ssl-connections. Optionally a certificate- and key-file can be passed.
Example
SslListen 192.168.0.1 8443
ThreadStartDelay ms
Example
ThreadStartDelay 1000
User username
Changes the user under which tntnet answers requests.
Example
User www-data
VMapUrl host url component-identifier [ path-info { additional-arguments } ]
This is like MapUrl, but is specific for the virtual host. This rule matches only if the host and the url matches against the specified
values. Both are regular-expressions, so one rule can also match multiple hosts.
Example
# maps request for the host www1.tntnet.org to application1 VMapUrl www1.tntnet.org /([^/.]+) $1@application1 # maps request for the host
www2.tntnet.org to application2 VMapUrl www2.tntnet.org /([^/.]+) $1@application2 # maps all calls to port 8000 to myapp VMapUrl .*:8000
/([^/.]+) $1@myapp
AUTHOR
This manual page was written by Tommi Makitalo <tommi@tntnet.org>.
SEE ALSO
tntnet(1) tntnet.properties(7).
Tntnet 2006-08-13 tntnet.conf(7)