Forum: Ruby on Rails RE: hosting multiple rails apps in one webroot?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Hogan, Brian P. (Guest)
on 2006-03-07 21:20
(Received via mailing list)
It's actually REALLY easy with lighttpd on linux.

Two apps...

Myserver.com/code/    => /apps/code/
Myserver.com/test/    +> /apps/test/



Each application needs this in the environment.rb

/apps/code/config/environment.rb

ActionController::AbstractRequest.relative_url_root = "/code"

/apps/test/config/environment.rb

ActionController::AbstractRequest.relative_url_root = "/test"



Here's a lighttpd config file that runs on port 80. Be sure to activate
mod_alias!!


# Default configuration file for the lighttpd web server
# Start using ./script/server lighttpd

server.port = 80
server.modules           = ("mod_alias",  "mod_rewrite",
"mod_accesslog", "mod_fastcgi" )
server.document-root     = "/apps/root/"
url.rewrite              = ( "^/$" => "index.html", "^([^.]+)$" =>
"$1.html" )

$HTTP["url"] =~ "^/code" {
  server.document-root = "/apps/code/public/"
  alias.url = ( "/code" => "/apps/code/public" )
  server.error-handler-404 = "/code/dispatch.fcgi"
  server.errorlog          = "/apps/code/log/lighttpd.error.log"
  accesslog.filename       = "/apps/code/log/lighttpd.access.log"
  server.indexfiles = ( "dispatch.fcgi", "index.html" )

  fastcgi.server = ( ".fcgi" =>
    ((
       "socket" => "/apps/code/log/code.socket",
       "min-procs" => 2,
       "max-procs" => 2,
       "bin-path" =>  "/apps/code/public/dispatch.fcgi",
       "bin-environment" => ( "RAILS_ENV" => "production" )
  )))
}

$HTTP["url"] =~ "^/test" {
  server.document-root = "/apps/test/public/"
  alias.url = ( "/test" => "/apps/test/public" )
  server.error-handler-404 = "/test/dispatch.fcgi"
  server.errorlog          = "/apps/test/log/lighttpd.error.log"
  accesslog.filename       = "/apps/test/log/lighttpd.access.log"
  server.indexfiles = ( "dispatch.fcgi", "index.html" )

  fastcgi.server = ( ".fcgi" =>
    ((
       "socket" => "/apps/test/log/test.socket",
       "min-procs" => 2,
       "max-procs" => 2,
       "bin-path" =>  "/apps/test/public/dispatch.fcgi",
       "bin-environment" => ( "RAILS_ENV" => "production" )
  )))
}




mimetype.assign = (
  ".css"        =>  "text/css",
  ".gif"        =>  "image/gif",
  ".htm"        =>  "text/html",
  ".html"       =>  "text/html",
  ".jpeg"       =>  "image/jpeg",
  ".jpg"        =>  "image/jpeg",
  ".js"         =>  "text/javascript",
  ".png"        =>  "image/png",
  ".swf"        =>  "application/x-shockwave-flash",
  ".txt"        =>  "text/plain"
)
--------------

Doing this with SCGI is just as easy. Just change the appropriate
sections and it should work fine.

Good luck!!!

-Brian
Stephen Bannasch (Guest)
on 2006-03-16 06:33
(Received via mailing list)
Brian,

Your config listed below ALMOST worked ...

In the $HTTP["url"] conditional config blocks I had to change:
  server.error-handler-404 = "/code/dispatch.fcgi"
to
  server.error-handler-404 = "dispatch.fcgi"

I'm using lighttpd 1.4.11 on MacOS X 10.4.5.

I hadn't realized how convoluted the process lighttpd uses is in order
to get to my rails apps. I enabled lighttpd debugging and carefully
watched the error log. When I connect to the url:
host.com/railsapp1/controller/method lighttpd first discovers that the
file:
  /Users/stephen/dev/rails/railsapp1/public/controller/method
doesn't exist before connecting to:
  /Users/stephen/dev/rails/railsapp1/public/dispatch.fcgi
and passing in the route:
  /railsapp1/controller/method
Which works because the following param in config/environment.rb (thanks
for pointing it out):
  ActionController::AbstractRequest.relative_url_root = "/railsapp1"
gets rails to strip the leading appname before routing.

So for anybody else who is interested example here's the conditional
config block for one of my test apps which is accessed via url:
host.com/railsapp1

$HTTP["url"] =~ "^/railsapp1" {
  server.document-root = "/Users/stephen/dev/rails/railsapp1/public/"
  alias.url = ( "/railsapp1" =>
"/Users/stephen/dev/rails/railsapp1/public" )
  accesslog.filename   =
"/Users/stephen/dev/rails/railsapp1/log/access.log"
  server.error-handler-404 = "dispatch.fcgi"
  server.errorlog          =
"/Users/stephen/dev/rails/railsapp1/log/lighttpd.error.log"
  server.indexfiles = ( "dispatch.fcgi", "index.html" )
  # rails stuff
  fastcgi.server = ( ".fcgi" =>
    (
        (
       "socket" => "/Users/stephen/dev/rails/railsapp1/log/code.socket",
       "min-procs" => 2,
       "max-procs" => 2,
       "bin-path" =>
"/Users/stephen/dev/rails/railsapp1/public/dispatch.fcgi",
       "bin-environment" => ( "RAILS_ENV" => "development" )
  )))
}

Thanks for your suggestion.

At 2:16 PM -0600 3/7/06, Hogan, Brian P. wrote:
>
>Here's a lighttpd config file that runs on port 80. Be sure to activate mod_alias!!
>$HTTP["url"] =~ "^/code" {
>       "min-procs" => 2,
>  server.errorlog          = "/apps/test/log/lighttpd.error.log"
>  )))
>  ".jpeg"       =>  "image/jpeg",
>Good luck!!!
>
>-Brian


--

-- Stephen Bannasch
   Director of Technology, Concord Consortium
   10 Concord Crossing, Suite 300, Concord, MA 01742
   direct and fax: 978 405-3209 main: 978 405 3200
   http://www.concord.org  mailto:stephen@concord.org
Bart Braem (Guest)
on 2006-03-16 16:18
(Received via mailing list)
Stephen Bannasch wrote:

>   server.error-handler-404 = "dispatch.fcgi"
>        "bin-path" =>
>        "/Users/stephen/dev/rails/railsapp1/public/dispatch.fcgi",
>        "bin-environment" => ( "RAILS_ENV" => "development" )
>   )))
> }
>

I can't get this config to work, strange... I have an Apache running at
the
public address with below in the config:
ProxyPass /cookbook http://localhost:3000/cookbook
ProxyPassReverse /cookbook http://localhost:3000/cookbook

Then I use the following lighttpd config:
# Default configuration file for the lighttpd web server
# Start using ./script/server lighttpd

server.port = 3000

server.modules           = ( "mod_rewrite", "mod_accesslog",
"mod_fastcgi" ,
"mod_alias" )
# server.error-handler-404 = "/dispatch.fcgi"
server.document-root     = "/home/bbraem/cookbook/public"
server.event-handler     = "freebsd-kqueue"
# server.indexfiles = ( "dispatch.fcgi", "index.html" )

# server.errorlog          = "log/lighttpd.error.log"
# accesslog.filename       = "log/lighttpd.access.log"

# url.rewrite              = ( "^/$" => "index.html", "^([^.]+)$" =>
"$1.html" )

# Change *-procs to 2 if you need to use Upload Progress or other tasks
that
# *need* to execute a second request while the first is still pending.
# fastcgi.server = ( ".fcgi" =>
#   ( "localhost" =>
#       (
#         "min-procs" => 1,
#         "max-procs" => 1,
#         "socket"    => "log/fcgi.socket",
#         "bin-path"  => "/home/bbraem/cookbook/public/dispatch.fcgi",
#         "bin-environment" => ( "RAILS_ENV" => "development" )
#       )
#   )
# )

$HTTP["url"] =~ "^/cookbook" {
  server.document-root = "/home/bbraem/cookbook/public/"
  alias.url = ( "/cookbook" => "/home/bbraem/cookbook/public" )
  accesslog.filename   = "/home/bbraem/cookbook/log/access.log"
  server.error-handler-404 = "dispatch.fcgi"
  server.errorlog          =
"/home/bbraem/cookbook/log/lighttpd.error.log"
  server.indexfiles = ( "dispatch.fcgi", "index.html" )
  # rails stuff
  fastcgi.server = ( ".fcgi" =>
    (
        (
       "socket" => "/home/bbraem/cookbook/log/code.socket",
       "min-procs" => 2,
       "max-procs" => 2,
       "bin-path" =>  "/home/bbraem/cookbook/public/dispatch.fcgi",
       "bin-environment" => ( "RAILS_ENV" => "development" )
  )))
}

mimetype.assign = (
  ".css"        =>  "text/css",
  ".gif"        =>  "image/gif",
  ".htm"        =>  "text/html",
  ".html"       =>  "text/html",
  ".jpeg"       =>  "image/jpeg",
  ".jpg"        =>  "image/jpeg",
  ".js"         =>  "text/javascript",
  ".png"        =>  "image/png",
  ".swf"        =>  "application/x-shockwave-flash",
  ".txt"        =>  "text/plain"
)


When starting this config I get no problems, but surfing to
host.com/cookbook or host.com/cookbook/ gives routing errors for "" and
"/". Does this work with your index.html?
Stephen Bannasch (Guest)
on 2006-03-16 19:32
(Received via mailing list)
Bart,

>When starting this config I get no problems, but surfing to
>host.com/cookbook or host.com/cookbook/ gives routing errors for "" and
>"/". Does this work with your index.html?

Does the file cookbook/public/index.html exist?
Does host.com/cookbook/index.html work? If this works and
host.com/cookbook doesn't change the order of index.html and
dispatch.fcgi in your config block:

  server.indexfiles = ( "index.html", "dispatch.fcgi" )

Lighttpd will now first look for the presence of index.html when serving
a directory and only when not found look for dispatch.fcgi in the same
dir.

Or leave it the way it is and add the following line to the END of
cookbook/config/routes.rb:

  map.connect '', :controller => 'recipe', :action => 'list'

Set the :controller and :action to point to what you would like your app
to display on entry at the top.

You need to decide whether you want lighttpd to serve up any index.html
files for your rails app at all. You can instead handle this kind of url
request by specifying a default route.

FYI: When I was trying to fix my earlier problems I was having I turned
on the debugging flags for lighttpd in lighttpd.conf. The debugging data
appear in lighttpd.error.log.

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

--

-- Stephen Bannasch
   Director of Technology, Concord Consortium
   10 Concord Crossing, Suite 300, Concord, MA 01742
   direct and fax: 978 405-3209 main: 978 405 3200
   http://www.concord.org  mailto:stephen@concord.org
Bart Braem (Guest)
on 2006-03-17 09:52
(Received via mailing list)
Stephen,

> Does the file cookbook/public/index.html exist?
> Does host.com/cookbook/index.html work?

The file exists and the url works.

> If this works and
> host.com/cookbook doesn't change the order of index.html and dispatch.fcgi
> in your config block:
>
>   server.indexfiles = ( "index.html", "dispatch.fcgi" )
>
> Lighttpd will now first look for the presence of index.html when serving a
> directory and only when not found look for dispatch.fcgi in the same dir.
>

I tried that but it does not seem to help, strange. I guess there is
something wrong with my rewrite rules, here's what I get when debugging
is
turned on (thanks for that hint!). The urls are: host.com/cookbook,
host.com/cookbook/, host.com/cookbook/index.html.

2006-03-17 09:38:27: (response.c.196) -- splitting Request-URI
2006-03-17 09:38:27: (response.c.197) Request-URI  :  /cookbook
2006-03-17 09:38:27: (response.c.198) URI-scheme   :  http
2006-03-17 09:38:27: (response.c.199) URI-authority:  localhost:3000
2006-03-17 09:38:27: (response.c.200) URI-path     :  /cookbook
2006-03-17 09:38:27: (response.c.201) URI-query    :
2006-03-17 09:38:27: (response.c.196) -- splitting Request-URI
2006-03-17 09:38:27: (response.c.197) Request-URI  :  //cookbook.html
2006-03-17 09:38:27: (response.c.198) URI-scheme   :  http
2006-03-17 09:38:27: (response.c.199) URI-authority:  localhost:3000
2006-03-17 09:38:27: (response.c.200) URI-path     :  //cookbook.html
2006-03-17 09:38:27: (response.c.201) URI-query    :
2006-03-17 09:38:27: (response.c.251) -- sanatising URI
2006-03-17 09:38:27: (response.c.252) URI-path     :  /cookbook.html
2006-03-17 09:38:27: (response.c.360) -- before doc_root
2006-03-17 09:38:27: (response.c.361)
Doc-Root     : /home/bbraem/cookbook/public/
2006-03-17 09:38:27: (response.c.362) Rel-Path     : /cookbook.html
2006-03-17 09:38:27: (response.c.363) Path         :
2006-03-17 09:38:27: (response.c.411) -- after doc_root
2006-03-17 09:38:27: (response.c.412)
Doc-Root     : /home/bbraem/cookbook/public/
2006-03-17 09:38:27: (response.c.413) Rel-Path     : /cookbook.html
2006-03-17 09:38:27: (response.c.414)
Path         : /home/bbraem/cookbook/public/cookbook.html
2006-03-17 09:38:27: (response.c.431) -- logical -> physical
2006-03-17 09:38:27: (response.c.432)
Doc-Root     : /home/bbraem/cookbook/public/
2006-03-17 09:38:27: (response.c.433) Rel-Path     : /cookbook.html
2006-03-17 09:38:27: (response.c.434)
Path         : /home/bbraem/cookbook/public.html
2006-03-17 09:38:27: (response.c.451) -- handling physical path
2006-03-17 09:38:27: (response.c.452)
Path         : /home/bbraem/cookbook/public.html
2006-03-17 09:38:27: (response.c.492) -- file not found
2006-03-17 09:38:27: (response.c.493)
Path         : /home/bbraem/cookbook/public.html
2006-03-17 09:38:27: (response.c.196) -- splitting Request-URI
2006-03-17 09:38:27: (response.c.197) Request-URI  :  dispatch.fcgi
2006-03-17 09:38:27: (response.c.198) URI-scheme   :  http
2006-03-17 09:38:27: (response.c.199) URI-authority:  localhost:3000
2006-03-17 09:38:27: (response.c.200) URI-path     :  dispatch.fcgi
2006-03-17 09:38:27: (response.c.201) URI-query    :
2006-03-17 09:38:27: (response.c.251) -- sanatising URI
2006-03-17 09:38:27: (response.c.252) URI-path     :  /dispatch.fcgi
2006-03-17 09:38:27: (response.c.360) -- before doc_root
2006-03-17 09:38:27: (response.c.361)
Doc-Root     : /home/bbraem/cookbook/public/
2006-03-17 09:38:27: (response.c.362) Rel-Path     : /dispatch.fcgi
2006-03-17 09:38:27: (response.c.363) Path         :
2006-03-17 09:38:27: (response.c.411) -- after doc_root
2006-03-17 09:38:27: (response.c.412)
Doc-Root     : /home/bbraem/cookbook/public/
2006-03-17 09:38:27: (response.c.413) Rel-Path     : /dispatch.fcgi
2006-03-17 09:38:27: (response.c.414)
Path         : /home/bbraem/cookbook/public/dispatch.fcgi
2006-03-17 09:38:27: (response.c.431) -- logical -> physical
2006-03-17 09:38:27: (response.c.432)
Doc-Root     : /home/bbraem/cookbook/public/
2006-03-17 09:38:27: (response.c.433) Rel-Path     : /dispatch.fcgi
2006-03-17 09:38:27: (response.c.434)
Path         : /home/bbraem/cookbook/public/dispatch.fcgi
2006-03-17 09:38:27: (response.c.451) -- handling physical path
2006-03-17 09:38:27: (response.c.452)
Path         : /home/bbraem/cookbook/public/dispatch.fcgi
2006-03-17 09:38:27: (response.c.459) -- file found
2006-03-17 09:38:27: (response.c.460)
Path         : /home/bbraem/cookbook/public/dispatch.fcgi
2006-03-17 09:38:27: (response.c.582) -- handling subrequest
2006-03-17 09:38:27: (response.c.583)
Path         : /home/bbraem/cookbook/public/dispatch.fcgi
2006-03-17 09:38:27: (mod_fastcgi.c.3549) handling it in mod_fastcgi
2006-03-17 09:38:27: (connections.c.1394) Warning: Either the
error-handler
returned status 404 or the error-handler itself was not found:
dispatch.fcgi
2006-03-17 09:38:27: (connections.c.1396) returning the original status
404
2006-03-17 09:38:27: (connections.c.1398) If this is a rails app: check
your
production.log
2006-03-17 09:38:27: (response.c.111) Response-Header:
HTTP/1.1 404 Not Found


2006-03-17 09:38:29: (response.c.196) -- splitting Request-URI
2006-03-17 09:38:29: (response.c.197) Request-URI  :  /cookbook/
2006-03-17 09:38:29: (response.c.198) URI-scheme   :  http
2006-03-17 09:38:29: (response.c.199) URI-authority:  localhost:3000
2006-03-17 09:38:29: (response.c.200) URI-path     :  /cookbook/
2006-03-17 09:38:29: (response.c.201) URI-query    :
2006-03-17 09:38:29: (response.c.196) -- splitting Request-URI
2006-03-17 09:38:29: (response.c.197) Request-URI  :  //cookbook/.html
2006-03-17 09:38:29: (response.c.198) URI-scheme   :  http
2006-03-17 09:38:29: (response.c.199) URI-authority:  localhost:3000
2006-03-17 09:38:29: (response.c.200) URI-path     :  //cookbook/.html
2006-03-17 09:38:29: (response.c.201) URI-query    :
2006-03-17 09:38:29: (response.c.251) -- sanatising URI
2006-03-17 09:38:29: (response.c.252) URI-path     :  /cookbook/.html
2006-03-17 09:38:29: (response.c.360) -- before doc_root
2006-03-17 09:38:29: (response.c.361)
Doc-Root     : /home/bbraem/cookbook/public/
2006-03-17 09:38:29: (response.c.362) Rel-Path     : /cookbook/.html
2006-03-17 09:38:29: (response.c.363) Path         :
2006-03-17 09:38:29: (response.c.411) -- after doc_root
2006-03-17 09:38:29: (response.c.412)
Doc-Root     : /home/bbraem/cookbook/public/
2006-03-17 09:38:29: (response.c.413) Rel-Path     : /cookbook/.html
2006-03-17 09:38:29: (response.c.414)
Path         : /home/bbraem/cookbook/public/cookbook/.html
2006-03-17 09:38:29: (response.c.431) -- logical -> physical
2006-03-17 09:38:29: (response.c.432)
Doc-Root     : /home/bbraem/cookbook/public/
2006-03-17 09:38:29: (response.c.433) Rel-Path     : /cookbook/.html
2006-03-17 09:38:29: (response.c.434)
Path         : /home/bbraem/cookbook/public/.html
2006-03-17 09:38:29: (response.c.451) -- handling physical path
2006-03-17 09:38:29: (response.c.452)
Path         : /home/bbraem/cookbook/public/.html
2006-03-17 09:38:29: (response.c.492) -- file not found
2006-03-17 09:38:29: (response.c.493)
Path         : /home/bbraem/cookbook/public/.html
2006-03-17 09:38:29: (response.c.196) -- splitting Request-URI
2006-03-17 09:38:29: (response.c.197) Request-URI  :  dispatch.fcgi
2006-03-17 09:38:29: (response.c.198) URI-scheme   :  http
2006-03-17 09:38:29: (response.c.199) URI-authority:  localhost:3000
2006-03-17 09:38:29: (response.c.200) URI-path     :  dispatch.fcgi
2006-03-17 09:38:29: (response.c.201) URI-query    :
2006-03-17 09:38:29: (response.c.251) -- sanatising URI
2006-03-17 09:38:29: (response.c.252) URI-path     :  /dispatch.fcgi
2006-03-17 09:38:29: (response.c.360) -- before doc_root
2006-03-17 09:38:29: (response.c.361)
Doc-Root     : /home/bbraem/cookbook/public/
2006-03-17 09:38:29: (response.c.362) Rel-Path     : /dispatch.fcgi
2006-03-17 09:38:29: (response.c.363) Path         :
2006-03-17 09:38:29: (response.c.411) -- after doc_root
2006-03-17 09:38:29: (response.c.412)
Doc-Root     : /home/bbraem/cookbook/public/
2006-03-17 09:38:29: (response.c.413) Rel-Path     : /dispatch.fcgi
2006-03-17 09:38:29: (response.c.414)
Path         : /home/bbraem/cookbook/public/dispatch.fcgi
2006-03-17 09:38:29: (response.c.431) -- logical -> physical
2006-03-17 09:38:29: (response.c.432)
Doc-Root     : /home/bbraem/cookbook/public/
2006-03-17 09:38:29: (response.c.433) Rel-Path     : /dispatch.fcgi
2006-03-17 09:38:29: (response.c.434)
Path         : /home/bbraem/cookbook/public/dispatch.fcgi
2006-03-17 09:38:29: (response.c.451) -- handling physical path
2006-03-17 09:38:29: (response.c.452)
Path         : /home/bbraem/cookbook/public/dispatch.fcgi
2006-03-17 09:38:29: (response.c.459) -- file found
2006-03-17 09:38:29: (response.c.460)
Path         : /home/bbraem/cookbook/public/dispatch.fcgi
2006-03-17 09:38:29: (response.c.582) -- handling subrequest
2006-03-17 09:38:29: (response.c.583)
Path         : /home/bbraem/cookbook/public/dispatch.fcgi
2006-03-17 09:38:29: (mod_fastcgi.c.3549) handling it in mod_fastcgi
2006-03-17 09:38:29: (connections.c.1394) Warning: Either the
error-handler
returned status 404 or the error-handler itself was not found:
dispatch.fcgi
2006-03-17 09:38:29: (connections.c.1396) returning the original status
404
2006-03-17 09:38:29: (connections.c.1398) If this is a rails app: check
your
production.log
2006-03-17 09:38:29: (response.c.111) Response-Header:
HTTP/1.1 404 Not Found


2006-03-17 09:38:33: (response.c.196) -- splitting Request-URI
2006-03-17 09:38:33: (response.c.197) Request-URI  :
/cookbook/index.html
2006-03-17 09:38:33: (response.c.198) URI-scheme   :  http
2006-03-17 09:38:33: (response.c.199) URI-authority:  localhost:3000
2006-03-17 09:38:33: (response.c.200) URI-path     :
/cookbook/index.html
2006-03-17 09:38:33: (response.c.201) URI-query    :
2006-03-17 09:38:33: (response.c.251) -- sanatising URI
2006-03-17 09:38:33: (response.c.252) URI-path     :
/cookbook/index.html
2006-03-17 09:38:33: (response.c.360) -- before doc_root
2006-03-17 09:38:33: (response.c.361)
Doc-Root     : /home/bbraem/cookbook/public/
2006-03-17 09:38:33: (response.c.362) Rel-Path     :
/cookbook/index.html
2006-03-17 09:38:33: (response.c.363) Path         :
2006-03-17 09:38:33: (response.c.411) -- after doc_root
2006-03-17 09:38:33: (response.c.412)
Doc-Root     : /home/bbraem/cookbook/public/
2006-03-17 09:38:33: (response.c.413) Rel-Path     :
/cookbook/index.html
2006-03-17 09:38:33: (response.c.414)
Path         : /home/bbraem/cookbook/public/cookbook/index.html
2006-03-17 09:38:33: (response.c.431) -- logical -> physical
2006-03-17 09:38:33: (response.c.432)
Doc-Root     : /home/bbraem/cookbook/public/
2006-03-17 09:38:33: (response.c.433) Rel-Path     :
/cookbook/index.html
2006-03-17 09:38:33: (response.c.434)
Path         : /home/bbraem/cookbook/public/index.html
2006-03-17 09:38:33: (response.c.451) -- handling physical path
2006-03-17 09:38:33: (response.c.452)
Path         : /home/bbraem/cookbook/public/index.html
2006-03-17 09:38:33: (response.c.459) -- file found
2006-03-17 09:38:33: (response.c.460)
Path         : /home/bbraem/cookbook/public/index.html
2006-03-17 09:38:33: (response.c.582) -- handling subrequest
2006-03-17 09:38:33: (response.c.583)
Path         : /home/bbraem/cookbook/public/index.html
2006-03-17 09:38:33: (mod_staticfile.c.386) -- handling file as static
file
2006-03-17 09:38:33: (response.c.594) -- subrequest finished
2006-03-17 09:38:33: (response.c.111) Response-Header:
HTTP/1.1 304 Not Modified



> You need to decide whether you want lighttpd to serve up any index.html
> files for your rails app at all. You can instead handle this kind of url
> request by specifying a default route.
>
I'm also experiencing problems with images so I'd like this fixed with
index.html, of course my frontpage should become dynamic if I want my
application to be a little bit interesting...

Thanks for your response!
Bart
Stephen Bannasch (Guest)
on 2006-03-21 05:21
(Received via mailing list)
At 9:49 AM +0100 3/17/06, Bart Braem wrote:
>2006-03-17 09:38:27: (response.c.201) URI-query    :
>2006-03-17 09:38:27: (response.c.196) -- splitting Request-URI
>2006-03-17 09:38:27: (response.c.197) Request-URI  :  //cookbook.html
>2006-03-17 09:38:27: (response.c.198) URI-scheme   :  http
>2006-03-17 09:38:27: (response.c.199) URI-authority:  localhost:3000
>2006-03-17 09:38:27: (response.c.200) URI-path     :  //cookbook.html

It looks like some rewrite rule is changing cookbook to cookbook.html.
I'd suggest getting rid of any rewrite rules. The only thing like a
rewrite rule I have in my lighttpd.conf file is:

index-file.names            = ( "index.php", "index.html",
                                "index.htm", "default.htm",
"dispatch.fcgi")

>2006-03-17 09:38:29: (response.c.196) -- splitting Request-URI
>2006-03-17 09:38:29: (response.c.197) Request-URI  :  /cookbook/
>2006-03-17 09:38:29: (response.c.198) URI-scheme   :  http
>2006-03-17 09:38:29: (response.c.199) URI-authority:  localhost:3000
>2006-03-17 09:38:29: (response.c.200) URI-path     :  /cookbook/
>2006-03-17 09:38:29: (response.c.201) URI-query    :
>2006-03-17 09:38:29: (response.c.196) -- splitting Request-URI
>2006-03-17 09:38:29: (response.c.197) Request-URI  :  //cookbook/.html

Again the ".html" is being added. You can download the source for your
version of lighttpd and check what line 197 in response.c is doing OR
you can just comment out all your rewrite rules to see if that helps.

Now this one worked. I'll bet the rewrite rule saw the ".html" and
didn't activate.
Bart Braem (Guest)
on 2006-03-21 14:00
(Received via mailing list)
Stephen Bannasch wrote:

> It looks like some rewrite rule is changing cookbook to cookbook.html. I'd
> suggest getting rid of any rewrite rules. The only thing like a rewrite
> rule I have in my lighttpd.conf file is:
>
> index-file.names            = ( "index.php", "index.html",
>                                 "index.htm", "default.htm",
>                                 "dispatch.fcgi")

That did it! Thank you very much! I'll add this information to the wiki
as
soon as possible. This will help other people for sure. All I have to do
is
find a nice page to link this in.

Thanks again
Bart
Ro (Guest)
on 2006-03-21 23:08
That did it for me too! Just one small problem...

My css path is jacked up now. since my url is:

http://dev/ro/railsapp1/

it won't recognize for some reason where that css really is.

I hacked it and put it (stylesheets/) under the 'normal' server's
webroot (it works but not recommended) but I'm sure there's a way for it
to recognize it under it's own virtual path...i.e.
/home/ro/public_html/railsapp1/public/stylesheets/scaffold.css

this is my vhost conf:

1   $HTTP["url"] =~ "^/ro\/railsapp1" {
2     server.document-root = "/home/ro/public_html/railsapp1/public/"
3     alias.url = ( "/ro\/railsapp1" =>
"/home/ro/public_html/railsapp1/public" )
4     accesslog.filename   =
"/home/ro/public_html/railsapp1/log/access.log"
5     server.error-handler-404 = "dispatch.fcgi"
6     server.errorlog          =
"/home/ro/public_html/railsapp1/log/lighttpd.error.log"
7     server.indexfiles = ( "dispatch.fcgi", "index.html" )
8         # rails stuff
9         fastcgi.server = (
10           ".fcgi" => (
11             ( "socket" =>
"/home/ro/public_html/railsapp1/log/code.socket",
12               "min-procs" => 2,
13               "max-procs" => 2,
14               "bin-path" =>
"/home/ro/public_html/railsapp1/public/dispatch.fcgi",
15               "bin-environment" => ( "RAILS_ENV" => "development" )
16             ))
17           )
18   }


thanks,

ro

Bart Braem wrote:
> Stephen Bannasch wrote:
>
>> It looks like some rewrite rule is changing cookbook to cookbook.html. I'd
>> suggest getting rid of any rewrite rules. The only thing like a rewrite
>> rule I have in my lighttpd.conf file is:
>>
>> index-file.names            = ( "index.php", "index.html",
>>                                 "index.htm", "default.htm",
>>                                 "dispatch.fcgi")
>
> That did it! Thank you very much! I'll add this information to the wiki
> as
> soon as possible. This will help other people for sure. All I have to do
> is
> find a nice page to link this in.
>
> Thanks again
> Bart
Bart Braem (Guest)
on 2006-03-22 17:48
(Received via mailing list)
Bart Braem wrote:

> That did it! Thank you very much! I'll add this information to the wiki as
> soon as possible. This will help other people for sure. All I have to do
> is find a nice page to link this in.

I have added this information to
<http://wiki.rubyonrails.com/rails/pages/HowtoSetup...,
linked from
<http://wiki.rubyonrails.org/rails/pages/HowtosInst....

Any comments or additions are welcome of course!
Bart
Stephen Bannasch (Guest)
on 2006-03-22 18:31
(Received via mailing list)
>Any comments or additions are welcome of course!
>Bart

The lighttpd.conf section looks good.

The lighttpd.conf $HTTP[$url] configuration block technique can also be
used with or without Apache proxing and is very handy when you want to
host multiple raiils apps without making new subdomains.

re:

server.event-handler     = "freebsd-kqueue"
# this is for FreeBSD!

I usually put the comment just before the directive.
Stephen Bannasch (Guest)
on 2006-03-22 19:48
(Received via mailing list)
>to recognize it under it's own virtual path...i.e.
>/home/ro/public_html/railsapp1/public/stylesheets/scaffold.css

Did you try setting this in config/environment.rb:

 ActionController::AbstractRequest.relative_url_root = '/railsapp1'

add it at the bottom:
Ro (Guest)
on 2006-03-22 20:35
If you notice on this line:
  $HTTP["url"] =~ "^/ro\/railsapp1"

I have it under a main directory called /ro/ in lighty pointing to the
filesystem (/home/ro/public_html/railsapp1/public)

So I would, ideally, have:

http://dev/ro/railsapp1
http://dev/ro/railsapp2

What 'fixed' my problem is that I combined the name so that I ONLY have
one main directory per app:

Like so:   $HTTP["url"] =~ "^/rorailsapp1" ...
           $HTTP["url"] =~ "^/joerailsapp1" ...


http://dev/rorailsapp1 --> (/home/ro/public_html/railsapp1/public)

http://dev/joerailsapp1 --> (/home/joe/public_html/railsapp1/public)

So that I can have a nice CVS or Subversion type environment. Maybe I'm
not approaching this the right way. It works but It'd rather have it to
where the vhost is identified by user http://dev/ro/<all rails apps
here>... Does this make sense Stephen?

thanks,

-ro-

Stephen Bannasch wrote:
>>to recognize it under it's own virtual path...i.e.
>>/home/ro/public_html/railsapp1/public/stylesheets/scaffold.css
>
> Did you try setting this in config/environment.rb:
>
>  ActionController::AbstractRequest.relative_url_root = '/railsapp1'
>
> add it at the bottom:
This topic is locked and can not be replied to.