Security Features

Module: core

Author: Jan Kneschke
Date: 2004-08-29
Revision:

$

System Message: WARNING/2 (<string>, line 11)

Cannot extract compound bibliographic field "Revision".

Abstract

lighttpd was developed with security in mind ...

Description

System Security

Running daemons as root with full privileges is a bad idea in general. lighttpd runs best without any extra privileges and runs perfectly in chroot.

Change Root

server.chroot = "..."

Drop root privileges

server.username = "..."
server.groupname = "..."

FastCGI

In order to chroot a FastCGI server separately from lighttpd, there are a few extra steps to be aware of. First, configure lighttpd to expect an external FastCGI server, and set the docroot variable relative to the FastCGI server's chroot, rather than relative to lighttpd:

fastcgi.server = (".fcgi" =>
  (
    ( "docroot" => "/directories/past/chroot/"
    )
  )
)

Second, make sure that /bin/sh exists in the FastCGI server's chroot, with precisely that path, since spawn-fcgi depends on its presence inside the chroot.

Finally, pass '-u <user> -g <group> -c /path/to/chroot' as arguments to spawn-fcgi when starting the FastCGI server. As with chrooting lighttpd, it is important to run the FastCGI server as a user without root permissions, because root is able to escape chroot.

Permissions

to be documented

(the above text was originally taken directly from doc/security.txt)

Note that chroot is not the the ultimate security feature, but it is a reasonable additional step to take in securing your web server. Most importantly, setting up a chroot without dropping root privileges will have zero effect, as the root user can break out of chroot trivially. On some server platforms, other options such as FreeBSD Jail, Solaris Containers, or Virtualized servers may be superior options that don't directly involve the configuration of Lighttpd.