Mod setenv » History » Revision 16
Revision 15 (Olaf-van-der-Spek, 2019-04-27 07:49) → Revision 16/30 (gstrauss, 2019-05-04 22:30)
h1. Conditional Request Headers
{{>toc}}
*Module: mod_setenv*
h2. Description
The setenv module allows influencing the environment external applications are spawned in and the response headers the server sends to the clients.
Note: mod_setenv needs to be listed prior to mod_redirect in the @server.modules@ list in lighttpd.conf so that mod_setenv can set headers prior to the redirect. (Listing modules alphabetically is a common mistake. e.g. #2946)
h2. Automatic Decompression
If you have a lot text-files compressed with gzip on disk and want that the browser is decompressing them on retrieval you can use setenv to inject the Content-Encoding header:
<pre>
$HTTP["url"] =~ "(README|ChangeLog|\.txt)\.gz$" {
setenv.add-response-header = ( "Content-Encoding" => "gzip")
mimetype.assign = ("" => "text/plain" )
}
</pre>
h2. Options
*setenv.add-environment*
Adds a value to the process environment (aka environment variables) that is passed to the external applications:
<pre>
setenv.add-environment = (
"TRAC_ENV" => "lighttpd",
"RAILS_ENV" => "production"
)
</pre>
*setenv.add-response-header*
Adds a header to the HTTP response sent to the client:
<pre>
setenv.add-response-header = (
"Content-Encoding" => "gzip"
)
</pre>
*setenv.add-request-header*
Adds a header to the HTTP request that was received from the client:
<pre>
setenv.add-request-header = (
"X-Proxy" => server.name
)
</pre>
*setenv.set-request-header* (since 1.4.46)
*setenv.set-response-header* (since 1.4.46)
*setenv.set-environment* (since 1.4.46)
These directives _set_ the given values, rather than appending the given values to the headers or environment. These directives take precedence over the setenv.add-* counterparts. Set a blank value for request or response header to remove the header.