<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>lighty's life: lighttpd 1.4.8 and multiple rails-apps</title>
    <link>http://blog.lighttpd.net/articles/2005/11/23/lighttpd-1-4-8-and-multiple-rails-apps</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description></description>
    <item>
      <title>lighttpd 1.4.8 and multiple rails-apps</title>
      <description>&lt;p&gt;&lt;a href="http://www.lighttpd.net/download/"&gt;lighttpd 1.4.8&lt;/a&gt; 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.&lt;/p&gt;
&lt;p&gt;Next to the usual setup with fastcgi.server the new option &amp;#8216;strip-request-uri&amp;#8217; removes parts of the  request-uri before they are sent to the backend:&lt;/p&gt;


&lt;pre&gt;
$HTTP["url"] =~ "^/app1/" {
  server.document-root = "/home/jan/rails/app1/public/" 
  alias.url = ( "/app1/" =&amp;gt; "/home/jan/rails/app1/public/" )
  server.error-handler-404 = "/app1/dispatch.fcgi" 
  fastcgi.server = ( "/app1/dispatch.fcgi" =&amp;gt;
    (( "socket" =&amp;gt; "/tmp/app1.socket1",
       "bin-path" =&amp;gt;  "/home/jan/rails/app1/public/dispatch.fcgi",
       "strip-request-uri" =&amp;gt; "/app1/" 
  )))
}

$HTTP["url"] =~ "^/app2/" {
  server.document-root = "/home/jan/rails/app2/public/" 
  alias.url = ( "/app2/" =&amp;gt; "/home/jan/rails/app2/public/" )
  server.error-handler-404 = "/app2/dispatch.fcgi" 
  fastcgi.server = ( "/app2/dispatch.fcgi" =&amp;gt;
    (( "socket" =&amp;gt; "/tmp/app2.socket1",
       "bin-path" =&amp;gt;  "/home/jan/rails/app2/public/dispatch.fcgi",
       "strip-request-uri" =&amp;gt; "/app2" 
  )))
}
&lt;/pre&gt;

	&lt;p&gt;But why ?&lt;/p&gt;


Rails has a strict mapping of URLs to the application:
&lt;pre&gt;
/controller/action/parameter
&lt;/pre&gt;
and as soon as you want to run multiple rails apps at the same virtual host you will get the namespace-clashs. 

&lt;pre&gt;
/app1/controller/action/parameter
/app2/controller/action/parameter
&lt;/pre&gt;
looks better and all we have do now is stripping the /appx before we hand it over to rails.

	&lt;p&gt;Later we will add this option to mod_scgi and mod_proxy too or even add a rewrite at that level.&lt;/p&gt;</description>
      <pubDate>Wed, 23 Nov 2005 16:15:00 +0100</pubDate>
      <guid isPermaLink="false">urn:uuid:a451fe3c-384c-4886-9767-5e43b7bb8d83</guid>
      <author>jan</author>
      <link>http://blog.lighttpd.net/articles/2005/11/23/lighttpd-1-4-8-and-multiple-rails-apps</link>
      <category>rails</category>
      <trackback:ping>http://blog.lighttpd.net/articles/trackback/35</trackback:ping>
    </item>
  </channel>
</rss>
