Well, it was a pain in the ass, but I managed to get multiple Rails sites running with lighttpd on the same domain.
Here’s the interesting parts of the lighttpd.conf file that makes this magic shit work:
# needed for aliases to work
server.modules = ( "mod_rewrite", "mod_fastcgi", "mod_alias" )
$HTTP["url"] =~ "^/svn_browser/cisv" {
server.document-root = "/users/home/joevd/domains/joevandyk.com/cisv_collaboa/public/"
alias.url = ( "/svn_browser/cisv" => "/users/home/joevd/domains/joevandyk.com/cisv_collaboa/public" )
server.error-handler-404 = "/svn_browser/cisv/dispatch.fcgi"
server.indexfiles = ( "dispatch.fcgi", "index.html" )
fastcgi.server = ( ".fcgi" =>
((
"socket" => "/home/joevd/lighttpd/joevd_cisv_svn1.socket",
"min-procs" => 1,
"max-procs" => 1,
"bin-path" => "/users/home/joevd/domains/joevandyk.com/cisv_collaboa/public/dispatch.fcgi",
"bin-environment" => ( "RAILS_ENV" => "production" )
)))
}
$HTTP["url"] =~ "^/svn_browser/gamefest" {
server.document-root = "/users/home/joevd/domains/joevandyk.com/gamefest_collaboa/public/"
alias.url = ( "/svn_browser/gamefest" => "/users/home/joevd/domains/joevandyk.com/gamefest_collaboa/public" )
server.error-handler-404 = "/svn_browser/gamefest/dispatch.fcgi"
server.indexfiles = ( "dispatch.fcgi", "index.html" )
fastcgi.server = ( ".fcgi" =>
((
"socket" => "/home/joevd/lighttpd/joevd_gamefest_svn1.socket",
"min-procs" => 1,
"max-procs" => 1,
"bin-path" => "/users/home/joevd/domains/joevandyk.com/gamefest_collaboa/public/dispatch.fcgi",
"bin-environment" => ( "RAILS_ENV" => "production" )
)))
}
You also need to add the following to the app’s config/environment.rb file (at the very end):
ActionController::AbstractRequest.relative_url_root = "/svn_browser/cisv"
It’s a royal pain, but it’s pretty cool once you got a working configuration.
10 Responses to “Getting multiple Rails sites going on one domain using lighttpd”
Sorry, comments are closed for this article.
January 31st, 2006 at 01:45 PM
That is pretty neat. Looks awfully complicated though.
January 31st, 2006 at 02:28 PM
Yeah, lighttpd config files are ugly, imo. But they’re really powerful and flexible. And it’s a hella fast server.
February 6th, 2006 at 06:14 AM Sigh! I wish I had found this article first instead of this thread: on textdrive I tried out all the configurations in the other thread with no luck until I figured out this configuration that’s listed here.
For me the critical thing that I was missing was:
February 25th, 2006 at 05:40 AM
Glad it helped someone!
March 12th, 2006 at 05:55 AM
This is awesome!!! THANK YOU!!!!!!
I tinkered with these: http://blog.lighttpd.net/articles/2005/11/23/lighttpd-1-4-8-and-multiple-rails-apps http://serbiancafe.wordpress.com/2005/12/05/lighttpd-configuration-files-for-multiple-rails-apps/
And then I went onto technorati and found your site and after a bit of tweaking it worked!
Thank you.
March 14th, 2006 at 07:52 AM
Thanks—my config I’d posted on the TxD forums broke with lighttpd 1.4.9, and this helped me tweak it back to health.
March 15th, 2006 at 11:15 PM
Does this work with static files too? And with index.html? I can’t get it working here when using an Apache reverse proxy that redirects to localhost (without stripping of urls)
June 11th, 2006 at 08:10 PM
Yes Yes, thank you very much. I have been searching for this, and it actually works!
Rock on!
June 13th, 2006 at 05:16 PM
You should add this to the Rails Wiki in the HowtosDeployment section. It’s taken days for me to write the proper google query to find information that works.
June 16th, 2006 at 12:15 PM
Hm… yeah, I should probably publish this somewhere. Good thinking.