server.modules += ( "mod_accesslog", "mod_alias", "mod_cgi", "mod_redirect", "mod_rewrite", "mod_setenv" )

server.port = 80

# See here: https://redmine.lighttpd.net/boards/2/topics/8382
accesslog.filename = "/dev/fd/3"

server.document-root = "@site@"
index-file.names = ( "index.html" )

setenv.set-response-header += (
	"Content-Security-Policy" => "default-src 'self'; img-src 'self' data: https://photos.gutwe.in; script-src 'self' 'eval' 'unsafe-inline' https://hcaptcha.com https://*.hcaptcha.com https://bot.coderdojo-wue.de; frame-src 'self' https://hcaptcha.com https://*.hcaptcha.com; style-src 'self' 'unsafe-inline' https://hcaptcha.com https://*.hcaptcha.com; connect-src 'self' https://hcaptcha.com https://*.hcaptcha.com https://bot.coderdojo-wue.de; frame-ancestors 'none'",
)

#
# CGI / form handling
#

$HTTP["request-method"] =~ "GET|POST" {
	url.rewrite = (
		"^/anmelden" => "/cgi-bin/form.py",
		"^/freizeit" => "/cgi-bin/form.py",
	)
}

$HTTP["url"] =~ "^/cgi-bin/" {
	alias.url += ( "/cgi-bin" => "@cgibin@" )

	static-file.exclude-extensions = ( ".py" )
	cgi.assign = ( ".py" => "@python@" )
	cgi.execute-x-only = "enable"

	cgi.x-sendfile = "enable"
	cgi.x-sendfile-docroot = ( "@site@" )

	setenv.set-environment = (
		"SITE_DIRECTORY" => "@site@",
		"ZAMMAD_URL" => env.ZAMMAD_URL,
		"ZAMMAD_TOKEN" => env.ZAMMAD_TOKEN,
		"ZAMMAD_GROUP" => env.ZAMMAD_GROUP,
		"HCAPTCHA_SITE_KEY" => env.HCAPTCHA_SITE_KEY,
		"HCAPTCHA_SECRET_KEY" => env.HCAPTCHA_SECRET_KEY,
	)
}
