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

server.document-root = "/opt/api/www"
server.port = 8080
server.username = "www-data"
server.groupname = "www-data"
server.errorlog = "/opt/api/log/error.log"
accesslog.filename = "/opt/api/log/access.log"
dir-listing.activate = "disable"

alias.url = (
  "/mt-api/api.html" => "/opt/api/www/mt-api.cgi",
  "/mt-api/api" => "/opt/api/www/mt-api.cgi",
  "/mt-api" => "/opt/api/www/mt-api.cgi",
  "/css" => "/opt/api/www/css",
  "/web" => "/opt/api/www/web"
)

setenv.add-environment = (
  "LC_ALL" => "en_US.UTF-8",
  "LANG" => "en_US.UTF-8",
  "MT_API_DB_HOST" => env.MT_API_DB_HOST,
  "MT_API_DB_PORT" => env.MT_API_DB_PORT,
  "MT_API_DB_NAME" => env.MT_API_DB_NAME
)

url.rewrite-if-not-file = (
  "^/api\\.html$" => "/mt-api?mode=api",
  "^/api/(info|listChannels|listLivestream)$" => "/mt-api?mode=api&sub=$1",
  "^/api$" => "/mt-api?mode=api"
)

$HTTP["url"] == "/" {
  url.redirect = ( "" => "/mt-api" )
}

cgi.assign = ( ".cgi" => "/bin/sh" )
