server.modules += ("mod_rewrite", "mod_fastcgi", "mod_accesslog")
#

var.sb_prefix = "%%SB_PREFIX%%"

#var.sb_user = "%%SB_LIGHTTPD_USER%%"
#var.sb_group = "%%SB_LIGHTTPD_GROUP%%"

#var.sb_port = %%PORT%%
var.sb_port = 6443
var.sb_vhostname = "%%VHOST_NAME%%"
var.sb_hostip = "%%HOSTIP%%"
#var.sb_phppath = "/usr/bin/sw-php-cgi"
var.sb_phppath = "%%PHPPATH%%"
var.sb_accesslog = "%%ERRORLOGDIR%%"

#$HTTP["host"] == var.sb_vhostname {
$SERVER["socket"] == var.sb_hostip + ":" + var.sb_port {
		server.name 	 = var.sb_vhostname
#		server.port 	 = var.sb_port
		server.document-root = var.sb_prefix + "/htdocs"
#		server.username  = var.sb_user
#		server.groupname = var.sb_group

		accesslog.filename = var.sb_accesslog

		$HTTP["url"] =~ "/(index\.php|localizedimage\.php|check\.php|external_login\.php|preview\.php|ServiceFacade/.+\.asmx|wysiwyg/editor/.+\.php|js/Modules/Wysiwyg/editor/.+\.php|sites/.+/__(preview|edit)/.+\.php)" {
			fastcgi.server = (
				 "/" => ((
						"socket" => "/tmp/sitebuilder-php.socket",
						"broken-scriptfilename" => "enable",
						"bin-path" => var.sb_phppath + " -c " + var.sb_prefix + "/etc/php.ini",
						"max-procs" => 5,
						"min-procs" => 1,
						"idle-timeout" => 30
				))
			)
		} # $HTTP["url"]

#		fastcgi.map-extensions = (".asmx" => ".php")
#        fastcgi.server = (
#                ".php" => ((
#					"socket" => "/tmp/sitebuilder-php.socket",
#					"broken-scriptfilename" => "enable",
#					"bin-path" => var.sb_phppath + " -c " + var.sb_prefix + "/etc/php.ini",
#					"max-procs" => 5,
#					"min-procs" => 1,
#					"idle-timeout" => 30
#               )),
#        )

        index-file.names += ( "index.php" )
		# FIXME: additional content types are required for images (like wbmp?)
        mimetype.assign   = (
                        ".png"  => "image/png",
                        ".jpg"  => "image/jpeg",
                        ".jpeg" => "image/jpeg",
						".bmp"  => "image/bmp",
                        ".gif"  => "image/gif",
                        ".xml"  => "text/xml",
                        ".js"   => "text/javascript",
                        ".html" => "text/html",
						".jar"	=> "application/jar",
                        ".txt"  => "text/plain")
        url.rewrite-once = (
                "^/(ServiceFacade/|resources/|tmp/|modules/|skins/|sites/|templates/|wysiwyg/|images/|applet/|js/|check\.php|phpinfo\.php|robots\.txt|preview\.php|external_login\.php|index\.php|localizedimage\.php|favicon\.ico|blank\.html).*" => "$0",
                "(.*)" => "/index.php/$1"
        )
}

