lighttpd 1.4.8 and multiple rails-apps
lighttpd 1.4.8
was just released and next to a pile of bugfixes we
added a new option to fastcgi.server to allow a simple setup of multiple
rails app in one virtual host.
Next to the usual setup with fastcgi.server the new option
strip-request-uri removes parts of the request-uri before they are
sent to the backend:
$HTTP["url"] =~ "^/app1/" {
server.document-root = "/home/jan/rails/app1/public/"
alias.url = ( "/app1/" => "/home/jan/rails/app1/public/" )
server.error-handler-404 = "/app1/dispatch.fcgi"
fastcgi.server = ( "/app1/dispatch.fcgi" => ((
"socket" => "/tmp/app1.socket1",
"bin-path" => "/home/jan/rails/app1/public/dispatch.fcgi",
"strip-request-uri" => "/app1/"
)) )
}
$HTTP["url"] =~ "^/app2/" {
server.document-root = "/home/jan/rails/app2/public/"
alias.url = ( "/app2/" => "/home/jan/rails/app2/public/" )
server.error-handler-404 = "/app2/dispatch.fcgi"
fastcgi.server = ( "/app2/dispatch.fcgi" => ((
"socket" => "/tmp/app2.socket1",
"bin-path" => "/home/jan/rails/app2/public/dispatch.fcgi",
"strip-request-uri" => "/app2"
)) )
}
But why?
Rails has a strict mapping of URLs to the application:
and as soon as you want to run multiple rails apps at the same virtual host you will get the namespace-clashs.
looks better and all we have do now is stripping the /appx before we
hand it over to rails.
Later we will add this option to mod_scgi and mod_proxy too or even add
a rewrite at that level.