# lighttpd configuration file
#
# use it as a base for lighttpd 1.0.0 and above
#
# $Id: lighttpd.conf,v 1.7 2004/11/03 22:26:05 weigon Exp $

## modules to load
server.modules = ( "mod_rewrite",
		   "mod_redirect",
                   "mod_access",
                   "mod_auth",
                   "mod_status",
                   "mod_fastcgi",
                   "mod_accesslog",
                   "mod_dirlisting", 
                   "mod_alias" )

## enable debugging (default "disable")
# debug.log-request-header   = "enable"
# debug.log-response-header  = "enable"
# debug.log-request-handling = "enable"
# debug.log-file-not-found   = "enable"

## Globals ######################################################

ROOT        = "/var/www"
STATIC_ROOT = ROOT + "/pages"
RAILS_ROOT  = ROOT + "/pages/rails"
LOG_ROOT    = ROOT + "/logs"

### DEFAULT #####################################################

server.document-root       = RAILS_ROOT + "/wiki/public/"
server.error-handler-404   = "dispatch.fcgi"
index-file.names           = ( "dispatch.fcgi" )
server.pid-file            = "/var/run/lighttpd.pid"
server.tag                 = "lighttpd"
accesslog.filename         = LOG_ROOT + "/access.log"
server.errorlog            = LOG_ROOT + "/lighttpd.error.log"
server.port                = 80
# dir-listing.activate       = "enable"

# WIKI

fastcgi.server = ( ".fcgi" =>
  ( "localhost" => (
    "socket" => "/var/run/wiki.socket",
    "bin-path" => RAILS_ROOT + "/wiki/public/dispatch.fcgi",
    "min-procs" => 1,
    "max-procs" => 2,
    "bin-environment" => ( "RAILS_ENV" => "production" )
  ))
)

### Fix IE PDF problem ##########################################

$HTTP["url"] =~ "\.pdf$" {
  server.range-requests = "disable"
}

### STATIC ######################################################

$HTTP["url"] =~ "^/html/" {
  server.document-root        = STATIC_ROOT
  server.error-handler-404    = "error-404.html"
  index-file.names            = ( "index.html","index.htm" )
}


### WIKI ########################################################

$HTTP["host"] =~ "(www.)?lounge.se" {
  server.document-root = RAILS_ROOT + "/wiki/public/"
  server.error-handler-404 = "dispatch.fcgi"
  index-file.names         = ( "dispatch.fcgi" )

  fastcgi.server = ( ".fcgi" =>
    ( "localhost" => (
      "socket" => "/var/run/wiki.socket",
      "bin-path" => RAILS_ROOT + "/wiki/public/dispatch.fcgi",
      "min-procs" => 1,
      "max-procs" => 2,
      "bin-environment" => ( "RAILS_ENV" => "production" )
    ))
  )
}

$SERVER["socket"] == "192.168.0.2:81" {
  server.document-root = RAILS_ROOT + "/wiki/public/"
  server.error-handler-404 = "dispatch.fcgi"
  index-file.names         = ( "dispatch.fcgi" )
  server.port                = 80

  fastcgi.server = ( ".fcgi" =>
    ( "localhost" => (
      "socket" => "/var/run/wiki.socket",
      "bin-path" => RAILS_ROOT + "/wiki/public/dispatch.fcgi",
      "min-procs" => 1,
      "max-procs" => 2,
      "bin-environment" => ( "RAILS_ENV" => "production" )
    ))
  )
}

### EMAN ########################################################

$HTTP["host"] =~ "(www.)?dittlag.se" {
  server.document-root = RAILS_ROOT + "/eman/public/"
  server.error-handler-404 = "dispatch.fcgi"
  index-file.names         = ( "dispatch.fcgi" )

  fastcgi.server = ( ".fcgi" => 
    ( "localhost" => (
      "socket" => "/var/run/eman.socket",
      "bin-path" => RAILS_ROOT + "/eman/public/dispatch.fcgi",
      "min-procs" => 1,
      "max-procs" => 2,
      "bin-environment" => ( "RAILS_ENV" => "development" )
    ))
  )
}

$SERVER["socket"] == "192.168.0.2:82" {
  server.document-root = RAILS_ROOT + "/eman/public/"
  server.error-handler-404 = "dispatch.fcgi"
  index-file.names         = ( "dispatch.fcgi" )
  server.port                = 80

  fastcgi.server = ( ".fcgi" => 
    ( "localhost" => (
      "socket" => "/var/run/eman.socket",
      "bin-path" => RAILS_ROOT + "/eman/public/dispatch.fcgi",
      "min-procs" => 1,
      "max-procs" => 2,
      "bin-environment" => ( "RAILS_ENV" => "development" )
    ))
  )
}


## Do redirection to rails applications (not currently used)
# strip-request-uri doesn't work
# Add ActionController::AbstractRequest.relative_url_root = "/testapp"
# in environment.rb instead
# alias.url = ( "/eman/" => RAILS_ROOT + "/eman/public/" )

### MIMES #######################################################

mimetype.assign = (
  ".pdf"          =>      "application/pdf",
  ".ps"           =>      "application/postscript",
  ".tgz"          =>      "application/x-tgz",
  ".zip"          =>      "application/zip",
  ".mp3"          =>      "audio/mpeg",
  ".gif"          =>      "image/gif",
  ".jpg"          =>      "image/jpeg",
  ".jpeg"         =>      "image/jpeg",
  ".png"          =>      "image/png",
  ".css"          =>      "text/css",
  ".html"         =>      "text/html",
  ".htm"          =>      "text/html",
  ".js"           =>      "text/javascript",
  ".dtd"          =>      "text/xml",
  ".xml"          =>      "text/xml",
)
