Skip to content

Instantly share code, notes, and snippets.

@phlegx
Created May 13, 2012 20:21
Show Gist options
  • Save phlegx/2690028 to your computer and use it in GitHub Desktop.
Save phlegx/2690028 to your computer and use it in GitHub Desktop.
# Lighttpd modules needed by WebMCP
server.modules += (
"mod_cgi",
"mod_alias",
"mod_setenv",
"mod_rewrite",
"mod_redirect",
)
# Enable CGI-Execution of *.lua files through lua binary
#cgi.assign += ( ".lua" => "/__INSERT_LOCAL_FILE_PATH_TO_LUA_BINARY_HERE__/lua" )
cgi.assign += ( ".lua" => "/usr/bin/lua" )
# Connect external URLs to server static files and the webmcp cgi interface
alias.url += (
# "/webmcp-demo/static/" => "/__INSERT_LOCAL_FILE_PATH_TO_DEMO_APPLICATION_HERE__/static/",
# "/webmcp-demo/" => "/__INSERT_LOCAL_FILE_PATH_TO_WEBMCP_FRAMEWORK_HERE__/cgi-bin/" )
"/webmcp-demo/static/" => "/opt/webmcp/demo-app/static/",
"/webmcp-demo/" => "/opt/webmcp/framework/cgi-bin/" )
# Configure environment for demo application
$HTTP["url"] =~ "^/webmcp-demo/" {
setenv.add-environment += (
# "WEBMCP_APP_BASEPATH" => "/__INSERT_LOCAL_FILE_PATH_TO_DEMO_APPLICATION_HERE__",
"WEBMCP_APP_BASEPATH" => "/opt/webmcp/demo-app",
"WEBMCP_CONFIG_NAME" => "demo")
}
# URL beautification
url.rewrite-once += (
# do not rewrite static URLs
"^/webmcp-demo/static/(.*)$" =>
"/webmcp-demo/static/$1",
# base URL
"^/webmcp-demo/(\?(.*))?$" =>
"/webmcp-demo/webmcp-wrapper.lua?_webmcp_urldepth=0&_webmcp_module=index&_webmcp_view=index&$2",
# module base URLs
"^/webmcp-demo/([^/\?]+)/(\?(.*))?$" =>
"/webmcp-demo/webmcp-wrapper.lua?_webmcp_urldepth=1&_webmcp_module=$1&_webmcp_view=index&$3",
# actions
"^/webmcp-demo/([^/\?]+)/([^/\.\?]+)(\?(.*))?$" =>
"/webmcp-demo/webmcp-wrapper.lua?_webmcp_urldepth=1&_webmcp_module=$1&_webmcp_action=$2&$4",
# views without numeric id or string ident
"^/webmcp-demo/([^/\?]+)/([^/\.\?]+)\.([^/\?]+)(\?(.*))?$" =>
"/webmcp-demo/webmcp-wrapper.lua?_webmcp_urldepth=1&_webmcp_module=$1&_webmcp_view=$2&_webmcp_suffix=$3&$5",
# views with numeric id or string ident
"^/webmcp-demo/([^/\?]+)/([^/\?]+)/([^/\.\?]+)\.([^/\?]+)(\?(.*))?$" =>
"/webmcp-demo/webmcp-wrapper.lua?_webmcp_urldepth=2&_webmcp_module=$1&_webmcp_view=$2&_webmcp_id=$3&_webmcp_suffix=$4&$6",
)
# Redirects for URLs without trailing slashes
url.redirect += (
# base URL without trailing slash
"^/webmcp-demo$" => "/webmcp-demo/",
# module base URL without trailing slash
"^/webmcp-demo/([^/\?]+)$" => "/webmcp-demo/$1/",
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment