debug.log-request-header   = "enable"
debug.log-response-header  = "enable"
debug.log-request-handling = "enable"

server.systemd-socket-activation = "enable"
# optional bind spec override, e.g. for platforms without socket activation
include env.SRCDIR + "/tmp/bind*.conf"

server.document-root       = env.SRCDIR + "/tmp/lighttpd/servers/www.example.org/pages/"
server.errorlog            = env.SRCDIR + "/tmp/lighttpd/logs/lighttpd.error.log"
server.breakagelog         = env.SRCDIR + "/tmp/lighttpd/logs/lighttpd.breakage.log"
server.name                = "www.example.org"

server.compat-module-load = "disable"
server.modules += (
	"mod_auth",
	"mod_authn_file",
	"mod_fastcgi",
	"mod_accesslog",
)

accesslog.filename = env.SRCDIR + "/tmp/lighttpd/logs/lighttpd.access.log"

$HTTP["host"] == "auth.example.org" {

    server.name = "auth.example.org"

    $HTTP["url"] =$ ".php" {
	auth.backend.htpasswd.userfile = env.SRCDIR + "/lighttpd.htpasswd"
	auth.backend = "htpasswd"
	auth.require = (
		"" => (
			"method"  => "basic",
			"realm"   => "download archiv",
			"require" => "valid-user",
		),
	)
    }

    fastcgi.debug = 0
    fastcgi.server = (
	"/" => (
		"grisu-auth" => (
			"host" => "127.0.0.1",
			"port" => env.EPHEMERAL_PORT,
			"bin-path" => env.SRCDIR + "/fcgi-responder",
			"bin-copy-environment" => ( "PATH", "SHELL", "USER", ),
			"check-local" => "disable",
			"max-procs" => 1,
			"mode" => "authorizer",
		),
		"grisu-resp" => (
			"host" => "127.0.0.1",
			"port" => env.EPHEMERAL_PORT,
			"bin-path" => env.SRCDIR + "/fcgi-responder",
			"bin-copy-environment" => ( "PATH", "SHELL", "USER", ),
			"check-local" => "disable",
			"max-procs" => 1,
		),
	),
    )

}
else {

    fastcgi.debug = 0
    fastcgi.server = (
	".php" => ( (
		"host" => "127.0.0.1",
		"port" => env.EPHEMERAL_PORT,
		"bin-path" => env.SRCDIR + "/fcgi-responder",
		"bin-copy-environment" => ( "PATH", "SHELL", "USER", ),
		"check-local" => "disable",
		"max-procs" => 1,
	) ),
	"/prefix.fcgi" => ( (
		"host" => "127.0.0.1",
		"port" => env.EPHEMERAL_PORT,
		"bin-path" => env.SRCDIR + "/fcgi-responder",
		"max-procs" => 1,
	) ),
	".fcgi" => (
		"grisu" => (
			"host" => "127.0.0.1",
			"port" => env.EPHEMERAL_PORT,
			"bin-path" => env.SRCDIR + "/fcgi-responder",
			"bin-copy-environment" => ( "PATH", "SHELL", "USER", ),
			"check-local" => "disable",
			"max-procs" => 1,
		),
	),
    )

}

$HTTP["host"] == "wsgi.example.org" {
	fastcgi.server = (
		"/" => ( (
			"host" => "127.0.0.1",
			"port" => env.EPHEMERAL_PORT,
			"bin-path" => env.SRCDIR + "/fcgi-responder",
			"bin-copy-environment" => ( "PATH", "SHELL", "USER", ),
			"check-local" => "disable",
			"fix-root-scriptname" => "enable",
			"max-procs" => 1,
		) ),
	)
}
