<short>contains the core features for generic request handling, static files, log files and buffer limits.</short>
<sectiontitle="Socket addresses">
The following address formats can be used:
<sectiontitle="IPv4">
<textile>
Either with port @192.168.0.1:80@ or without @192.168.0.1@; you can either use real IPs or @0.0.0.0@ to listen on all network interfaces.
</textile>
</section>
<sectiontitle="IPv6">
<textile>
Similar to IPv4; just put the IPv6 between "[" and "]" like this: @[::1]:80@ (IPv6 localhost with port 80).
Please note that lighttpd always listens to IPv6 only (some platforms listen to IPv4 too on [::] by default).
</textile>
</section>
<sectiontitle="Unix domain sockets">
<textile>
A unix domain socket needs a filename where the socket is placed; use @unix:/path/to/socket@ as socket address.
Please don't put unix domain sockets in @/tmp@. Use @/var/run/lighttpd/@ or something like that, where only root or selected "trusted" users can create files.
This may be not supported in all places where a socket address can be specified.
</textile>
</section>
</section>
<sectiontitle="Options">
<optionname="debug.log_request_handling">
<short>enable debug output for request handling</short>
<default><value>false</value></default>
<example>
<config>
debug.log_request_handling true;
</config>
</example>
</option>
<optionname="static.range_requests">
<short>enabled ranged requests</short>
<default><value>true</value></default>
<example>
<config>
static.range_requests false;
</config>
</example>
</option>
<optionname="keepalive.timeout">
<short>how long a keep-alive connection is kept open (in seconds)</short>
<parametername="timeout"/>
<default><value>5</value></default>
<example>
<config>
keepalive.timeout 30;
</config>
</example>
</option>
<optionname="keepalive.requests">
<short>maximum number of requests a client is allowed to make in one connection</short>
<parametername="requests"/>
<default><value>0</value></default>
<example>
<config>
keepalive.requests 10;
</config>
</example>
</option>
<optionname="etag.use">
<short>list of properties used to calculate etag; specify empty list to disable etags. Available: "inode", "mtime", "size"</short>
If a filename is in lighttpd's stat "cache", lighttpd assumes the kernel still has the entry in memory, and @stat()@ therefore is unlikely to block.
Otherwise it will ask a background thread to call @stat()@, so the main worker threads are not waiting on a slow disk (or a network filesystem), but only if @stat.async@ is enabled.
If you know your disk is fast enough (perhaps a ramdisk?) and want to save the context switch to the background thread you can disable this.
</textile>
</description>
</option>
<optionname="buffer_request_body">
<short>enable buffering request body on disk</short>
<default><value>true</value></default>
<description>
<textile>
Some backends like to wait for the complete response before forwarding/handling it. For this they require this option to save some memory.
</textile>
</description>
</option>
<optionname="static.exclude_extensions">
<short>don't deliver static files with one of the listed extensions</short>
Default MIME type is "application/octet-stream". The sources contain a "mimetypes example config":http://git.lighttpd.net/lighttpd/lighttpd2.git/tree/contrib/mimetypes.conf with many standard mappings.
# if a directory was requested, first search for some default files
index ["index.php", "index.html", "/index.php"];
# if none of them did exists show a simple directory listing
dirlist;
# ... + handle PHP and static files
</config>
</example>
</action>
<actionname="pathinfo">
<short>splits physical path into existing file/directory and the remaining PATH_INFO</short>
<description>
<textile>
Searches for the longest prefix of the physical path name that exists, splitting only at the directory separator @/@; also never leaves the document root (technically speaking the filename can't get shorter than the document root).
</textile>
</description>
<example>
<description>
The following example maps @http://example.com/index.php/some/site@ to the file @/var/www/index.php@ with @PATH_INFO=/some/site@ (given @/var/www/index.php@ is a normal file).
</description>
<config>
docroot "/var/www";
pathinfo;
if phys.path =$ ".php" { fastcgi "unix:/var/run/lighttpd/php.sock"; }
</config>
</example>
<example>
<description>
The following example maps @http://example.com/some/site@ to the file @/var/www/index.php@ with @PATH_INFO=/some/site@ (given @/var/www/index.php@ is a normal file, and @/var/www/some@ does not exist).
</description>
<config>
docroot "/var/www";
pathinfo;
index ("index.php");
if phys.path =$ ".php" { fastcgi "unix:/var/run/lighttpd/php.sock"; }
</config>
</example>
</action>
</section>
<sectiontitle="Generating responses">
<actionname="static">
<short>handle GET and HEAD requests with a static file from disk</short>
<description>
<textile>
This action is automatically appended to the global config (unless a lua config is specified at the command line).
Does nothing if:
* the request is already handled
* no physical path was set (missing @docroot@, @alias@, ...)
* the physical path points to a directory
All other problems lead to an error page, for example:
<short>handle GET and HEAD requests with a static file from disk</short>
<description>
<textile>
same as @static@, but doesn't return any error pages; instead request handling continues.
</textile>
</description>
</action>
<actionname="respond">
<short>returns a quick response with optional body</short>
<parametername="status">
<short>HTTP response status code</short>
</parameter>
<parametername="content">
<short>(optional) pattern for response body</short>
</parameter>
<description>
<textile>
Generates a simple response (our favorite benchmark handler).
The body is parsed as "pattern":core_pattern.html#core_pattern.
</textile>
</description>
<example>
<config>
respond 403 => "Forbidden";
</config>
</example>
<example>
<config>
respond 200 => "benchmark content!";
</config>
</example>
</action>
</section>
<sectiontitle="Logging">
<sectiontitle="Log levels">
<textile>
For standard logging ("error.log") lighttpd knows the following levels:
* @debug@
* @info@
* @warning@
* @error@
* @abort@ (right before terminating the process)
* @backend@ (for log data from backends, like FastCGI stderr stream)
</textile>
</section>
<sectiontitle="Log targets">
<textile>
The following log targets are known:
* not logging: empty string
* files: @file:/var/log/error.log@ or just @/var/log/error.log@
* stderr: @stderr:@ or @stderr@
* syslog: @syslog:@ (not supported yet)
* pipes: @pipe:command@ or @| command@ (not supported yet)
Unknown strings are mapped to @stderr@.
</textile>
</section>
<actionname="log">
<short>overwrite log targets for all log levels</short>
<parametername="map">
<short>mapping log levels (or default) to log targets</short>
</parameter>
<example>
<config>
log [
"error" => "/var/log/lighttpd/error.log",
"abort" => "/var/log/lighttpd/error.log",
"backend" => "/var/log/lighttpd/backend.log",
default => "/var/log/lighttpd/debug.log",
];
</config>
</example>
</action>
<actionname="log.write">
<short>writes a log message to the "info" log level</short>
<parametername="message">
<short>message pattern string</short>
</parameter>
<description>
<textile>
Writes the specified message to the log using level @info@; the message is parsed as "pattern":core_pattern.html#core_pattern.
</textile>
</description>
<example>
<config>
log.write "hello world";
</config>
</example>
</action>
<setupname="log">
<short>sets default log targets for all log levels</short>
<parametername="map">
<short>mapping log levels (or default) to log targets</short>
</parameter>
<example>
<config>
setup {
log [
"error" => "/var/log/lighttpd/error.log",
"abort" => "/var/log/lighttpd/error.log",
"backend" => "/var/log/lighttpd/backend.log",
default => "/var/log/lighttpd/debug.log",
];
}
</config>
</example>
</setup>
<setupname="log.timestamp">
<short>sets the format string to use for timestamps in the log</short>
<parametername="format">
<short>a strftime format string</short>
</parameter>
<description>
<textile>
See "strftime":http://pubs.opengroup.org/onlinepubs/007904875/functions/strftime.html for the format string syntax.
The default format string is @"%d/%b/%Y %T %Z"@.
</textile>
</description>
</setup>
</section>
<sectiontitle="Connection environment">
<textile>
The connection environment is a set of variable with names and values (both simple strings). CGI backends will forward the environment in addition to the standard CGI environment variables.
The connection environment overwrites the standard CGI values.
</textile>
<actionname="env.set">
<short>sets a connection environment variable</short>
<parametername="name">
<short>the variable name to set</short>
</parameter>
<parametername="value">
<short>the pattern value to set</short>
</parameter>
<description>
<textile>
The value is parsed as "pattern":core_pattern.html#core_pattern.
</textile>
</description>
<example>
<config>
env.set "INFO" => "%{req.path}";
</config>
</example>
</action>
<actionname="env.add">
<short>sets a connection environment variable if not already set</short>
<parametername="name">
<short>the variable name to set</short>
</parameter>
<parametername="value">
<short>the pattern value to set</short>
</parameter>
<description>
<textile>
The value is parsed as "pattern":core_pattern.html#core_pattern. @env.add@ does not overwrite already existing values.
</textile>
</description>
<example>
<config>
env.add "INFO" => "%{req.path}";
</config>
</example>
</action>
<actionname="env.remove">
<short>removes a connection environment variable</short>
<parametername="name">
<short>the variable name to remove</short>
</parameter>
<example>
<config>
env.remove "INFO";
</config>
</example>
</action>
<actionname="env.clear">
<short>removes all connection environment variables</short>
<example>
<config>
env.clear;
</config>
</example>
</action>
</section>
<sectiontitle="Response header">
All header values that get set are parsed as "patterns":core_pattern.html#core_pattern.
<actionname="header.add">
<short>adds a new response header line</short>
<parametername="name">
<short>header name</short>
</parameter>
<parametername="value">
<short>pattern header value</short>
</parameter>
<description>
<textile>
The HTTP spec requires that multiple headers with the same name could be merged by joining their values with ",".
In real life this doesn't work always, especially not for "Cookie" headers; so this action actually adds a separate header line.
</textile>
</description>
<example>
<config>
header.add "Cache-Control" => "public";
</config>
</example>
</action>
<actionname="header.append">
<short>appends value to response header line</short>
<parametername="name">
<short>header name</short>
</parameter>
<parametername="value">
<short>pattern header value</short>
</parameter>
<description>
<textile>
If header already exists appends new value separated by ", "; otherwise adds a new header line.
</textile>
</description>
</action>
<actionname="header.overwrite">
<short>overwrite response header line or add new one</short>
<parametername="name">
<short>header name</short>
</parameter>
<parametername="value">
<short>pattern header value</short>
</parameter>
<description>
<textile>
If header already exists overwrites the value; otherwise a new line gets added.
</textile>
</description>
</action>
<actionname="header.remove">
<short>remove existing response header</short>
<parametername="name">
<short>header name</short>
</parameter>
<example>
<config>
# ... some PHP handling
# wait for response headers to be ready
if resp.status >= 0 {
header.remove "X-Powered-By";
}
</config>
</example>
</action>
<actionname="set_status">
<short>modify HTTP status code</short>
<description>
<textile>
Modifies the HTTP status code, but doesn't handle the request in any way.
Later actions could overwrite the status, or a backend (FastCGI, proxy, ...) might overwrite it if the response is parsed later.
Only works if some action actually handled the request.
Lighttpd will generate error pages (if it knows the code) if the action that handled the request didn't generate a response body and a body is allowed.
</textile>
</description>
<example>
<config>
# hide all 404s at end of config by setting 403
static;
if resp.status == 404 { set_status 403; }
</config>
</example>
</action>
</section>
<sectiontitle="Request headers">
All header values that get set are parsed as "patterns":core_pattern.html#core_pattern.
<actionname="req_header.add">
<short>adds a new request header line</short>
<parametername="name">
<short>header name</short>
</parameter>
<parametername="value">
<short>pattern header value</short>
</parameter>
<description>
<textile>
Same as "header.add":plugin_core.html#plugin_core__action_header-add for request headers.
</textile>
</description>
</action>
<actionname="req_header.append">
<short>appends value to request header line</short>
<parametername="name">
<short>header name</short>
</parameter>
<parametername="value">
<short>pattern header value</short>
</parameter>
<description>
<textile>
Same as "header.append":plugin_core.html#plugin_core__action_header-append for request headers.
</textile>
</description>
</action>
<actionname="req_header.overwrite">
<short>overwrite request header line or add new one</short>
<parametername="name">
<short>header name</short>
</parameter>
<parametername="value">
<short>pattern header value</short>
</parameter>
<description>
<textile>
Same as "header.overwrite":plugin_core.html#plugin_core__action_header-overwrite for request headers.
</textile>
</description>
</action>
<actionname="req_header.remove">
<short>remove existing request header</short>
<parametername="name">
<short>header name</short>
</parameter>
<description>
<textile>
Same as "header.remove":plugin_core.html#plugin_core__action_header-remove for request headers.
</textile>
</description>
<example>
<description>
<textile>
Remove @Accept-Encoding@ request header to workaround the "BREACH":http://en.wikipedia.org/wiki/BREACH_(security_exploit) vulnerability in https.
<short>set memory limit for outgoing chunkqueues (default is 256KiB)</short>
<parametername="limit">
<short>limit in bytes (0 means unlimited)</short>
</parameter>
<example>
<config>
io.buffer_out 512kbyte;
</config>
</example>
</action>
<actionname="io.buffer_in">
<short>set memory limit for intcoming chunkqueues (default is 256KiB)</short>
<parametername="limit">
<short>limit in bytes (0 means unlimited)</short>
</parameter>
<example>
<config>
io.buffer_in 512kbyte;
</config>
</example>
</action>
<actionname="map">
<short>maps the result of a pattern to a user defined action</short>
<parametername="pattern">
<short>the evaluation of this pattern is used as key in the mapping</short>
</parameter>
<parametername="mapping">
<short>maps strings (or default) to actions</short>
</parameter>
<description>
<textile>
The pattern is parsed as "pattern":core_pattern.html#core_pattern. Have a look at "mod_vhost":mod_vhost.html#mod_vhost for special mappings on hostnames.
</textile>
</description>
<example>
<config>
map "%{req.path}" => [
"/" => {
respond 200 => "root";
},
"/news" => {
respond 200 => "news";
},
default => {
respond 404;
},
];
</config>
</example>
</action>
<setupname="listen">
<short>listen to a socket address, see above for accepted formats (default TCP port is 80)</short>
<parametername="socket-address">
<short>socket address to listen to</short>
</parameter>
<example>
<config>
setup {
listen "0.0.0.0";
listen "[::]";
listen "127.0.0.1:8080";
}
</config>
</example>
</setup>
<setupname="workers">
<short>sets worker count; each worker runs in its own thread and works on the connections it gets assigned from the master worker</short>
<parametername="count">
<short>number of workers (default is 1)</short>
</parameter>
<example>
<config>
setup {
workers 2;
}
</config>
</example>
</setup>
<setupname="workers.cpu_affinity">
<short>binds worker threads to a cpu, only available on Linux systems</short>
<parametername="mapping">
<short>list of integers or a list of lists of integers</short>
</parameter>
<example>
<config>
workers.cpu_affinity [0, 1];
</config>
</example>
</setup>
<setupname="module_load">
<short>load the given module(s)</short>
<parametername="names">
<short>string or list of strings with the module name(s)</short>
</parameter>
<description>
modules can be "loaded" more than once without error
</description>
<example>
<config>
setup {
module_load "mod_rewrite";
}
</config>
</example>
</setup>
<setupname="io.timeout">
<short>sets the global I/O timeout (wait for network read and write)</short>
<parametername="timeout">
<short>timeout value in seconds, default is 300s</short>
</parameter>
</setup>
<setupname="stat_cache.ttl">
<short>set TTL for stat cache entries</short>
<parametername="ttl">
<short>time to live in seconds, default is 10s</short>
</parameter>
</setup>
<setupname="tasklet_pool.threads">
<short>sets number of background threads for blocking tasks</short>
<parametername="threads">
<short>number of threads</short>
</parameter>
<description>
<textile><![CDATA[
For example the stat cache uses such background threads.
if @threads = 0@ the tasks are run in foreground (no background threads).
if @threads < 0@allworkershareaGThreadPool.
if @threads > 0@ each worker has its own thread pool with @threads@ threads.
]]></textile>
</description>
</setup>
<setupname="fetch.files_static">
<short>starts a Fetch API provider</short>
<parametername="name">
<short>name of the storage</short>
</parameter>
<parametername="filename-pattern">
<short>A filename pattern including exactly on *</short>
</parameter>
<description>
Loads all filenames matching the wildcard pattern (which must include exactly on @*@) into the fetch storage.