# Multiple Rails apps with SCGI?

**URL:** <https://www.ruby-forum.com/t/multiple-rails-apps-with-scgi/49954>\
**Category:** Rails\
**Created:** [December 10, 2005, 10:02pm UTC](https://www.ruby-forum.com/t/multiple-rails-apps-with-scgi/49954 "2005-12-10T22:02:40Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![cool\_screen\_name900](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c68b51/32.png) [@cool\_screen\_name900](https://www.ruby-forum.com/u/cool_screen_name900)\
**Post date:** [December 10, 2005, 10:02pm UTC](https://www.ruby-forum.com/t/multiple-rails-apps-with-scgi/49954/1 "2005-12-10T22:02:40Z")

</div>

I have two different Rails directories and I’m trying to get scgi to  
serve both of them. There  
don’t appear to be any docs on how to do this. I thought perhaps it was  
cluster, but that appears  
to be just for concurrent connections in the same Rails directory. As it  
is now, I can get my  
first Rails directory to work, but the second just displays ‘bad  
gateway’ errors. I’ve started  
scgi in both Rails directories. I guess the missing link is in Lighty’s  
config, but I don’t know  
how to make requests for specific hosts go to specific scgi servers. My  
lighty config:

scgi.server = ( “dispatch.scgi” =\> ((  
“host” =\> “127.0.0.1”,  
“port” =\> 9999,  
“check-local” =\> “disable”,  
“disable-time”=\>0  
)) )

I also played around with clusters:

scgi.server = (  
“dispatch.scgi” =\> (  
“server1” =\> (  
“host” =\> “127.0.0.1”,  
“port” =\> 9999,  
“check-local” =\> “disable”,  
“disable-time” =\> 0  
),  
“server2” =\> (  
“host” =\> “127.0.0.1”,  
“port” =\> 10000,  
“check-local” =\> “disable”,  
“disable-time” =\> 0  
),  
“server3” =\> (  
“host” =\> “127.0.0.1”,  
“port” =\> 10001,  
“check-local” =\> “disable”,  
“disable-time” =\> 0  
),  
“server4” =\> (  
“host” =\> “127.0.0.1”,  
“port” =\> 10100,  
“check-local” =\> “disable”,  
“disable-time” =\> 0  
)  
)  
)

I set scgi in the second Rails directory to use port 10100. But I still  
get ‘bad gateway’ errors.  
I’ve tried everything I can think of and still can’t get it to work. Has  
anybody been able to get  
scgi to serve different Rails directories?

thanks for any help,  
csn

* * *

Do You Yahoo!?  
Tired of spam? Yahoo! Mail has the best spam protection around

> **[Yahoo Mail - Organized Email](https://mail.yahoo.com)**
>
> It's time to get stuff done with Yahoo Mail. Just add your Gmail, Outlook, AOL or Yahoo Mail to get going. We automatically organize all the things life throws at you, like receipts and attachments, so you can find what you need fast. Plus, we've got...

---

<div class="post-metadata">

**Author:** ![cool\_screen\_name900](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c68b51/32.png) [@cool\_screen\_name900](https://www.ruby-forum.com/u/cool_screen_name900)\
**Post date:** [December 10, 2005, 10:31pm UTC](https://www.ruby-forum.com/t/multiple-rails-apps-with-scgi/49954/2 "2005-12-10T22:31:11Z")

</div>

Hi, CSN,

don’t know how to do it with lighty, but I’m running multiple scgi apps  
as VirtualHosts on Apache. Therefore I’m starting scgi\_ctrl start with  
different ports on the different directorys and define the SCGI-Mounts  
in VirtualHost-directives that serve these directories. Maybe this is an  
option for you.

regards  
Jan

---

<div class="post-metadata">

**Author:** ![cool\_screen\_name900](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c68b51/32.png) [@cool\_screen\_name900](https://www.ruby-forum.com/u/cool_screen_name900)\
**Post date:** [December 10, 2005, 11:12pm UTC](https://www.ruby-forum.com/t/multiple-rails-apps-with-scgi/49954/3 "2005-12-10T23:12:04Z")

</div>

You need to make vhosts in lighttpd.conf for each rails app. So make  
one of these sections for each rails app with a different domain  
name. Here is a sample. vhost:

$HTTP[“host”] =~ “(www.)?example.com” {  
server.document-root = “/home/username/railsapp/public/”  
server.error-handler-404 = “/dispatch.scgi”  
server.indexfiles = ( “index.php”, “index.html”,  
“index.htm”, “default.htm” )  
scgi.debug=0  
scgi.server = ( “dispatch.scgi” =\> ((  
“host” =\> “127.0.0.1”,  
“port” =\> 9999,  
“check-local” =\> “disable”,  
“disable-time”=\>0  
)) )

}

Cheers-  
-Ezra

On Dec 10, 2005, at 1:00 PM, CSN wrote:

> how to make requests for specific hosts go to specific scgi
> 
> ```
> "port" => 10000,
> "host" => "127.0.0.1",
> 
> ```
> 
> work. Has anybody been able to get  
> Rails mailing list  
> removed\_email\_address@domain.invalid  
> [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

-Ezra Z.  
WebMaster  
Yakima Herald-Republic Newspaper  
removed\_email\_address@domain.invalid  
509-577-7732

---

<div class="post-metadata">

**Author:** ![cool\_screen\_name900](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c68b51/32.png) [@cool\_screen\_name900](https://www.ruby-forum.com/u/cool_screen_name900)\
**Post date:** [December 11, 2005, 12:21am UTC](https://www.ruby-forum.com/t/multiple-rails-apps-with-scgi/49954/4 "2005-12-11T00:21:35Z")

</div>

Aaahh… that was the missing link. Thanks!

I was curious to see if I could put scgi’s config params in just one  
vhost, and hopefully the  
global scgi params would be the default for all other vhosts that didn’t  
have scgi config stuff.  
Doesn’t appear to work - the vhost with scgi params worked, but the  
others displayed 404 errors.

csn

— Ezra Z. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> scgi.server = ( “dispatch.scgi” =\> ((
> 
> > scgi in both Rails directories. I guess the missing link is in
> > 
> > ```
> > "server2" => (
> > ),
> > 
> > ```
> > 
> > still get ‘bad gateway’ errors.  
> > [http://mail.yahoo.com](http://mail.yahoo.com)  
> > 509-577-7732
> 
> * * *
> 
> Rails mailing list  
> removed\_email\_address@domain.invalid  
> [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

* * *

Do You Yahoo!?  
Tired of spam? Yahoo! Mail has the best spam protection around

> **[\[object](https://mail.yahoo.com/)**
>
> \[object

---

<div class="post-metadata">

**Author:** ![cool\_screen\_name900](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c68b51/32.png) [@cool\_screen\_name900](https://www.ruby-forum.com/u/cool_screen_name900)\
**Post date:** [December 11, 2005, 4:58am UTC](https://www.ruby-forum.com/t/multiple-rails-apps-with-scgi/49954/5 "2005-12-11T04:58:32Z")

</div>

Also, you can use different local IP’s, keeping the ports the same. Try  
127.0.0.2, 127.0.0.3, etc.

---

<div class="post-metadata">

**Author:** ![cool\_screen\_name900](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c68b51/32.png) [@cool\_screen\_name900](https://www.ruby-forum.com/u/cool_screen_name900)\
**Post date:** [December 11, 2005, 12:21am UTC](https://www.ruby-forum.com/t/multiple-rails-apps-with-scgi/49954/6 "2005-12-11T00:21:35Z")

</div>

On Dec 10, 2005, at 2:59 PM, CSN wrote:

> csn

CSN-

```
Take a look at mod_simple_vhost. with that you can have a fall back

```

rails app for when nothing else matches.

Cheers-  
-Ezra

> > server.indexfiles = ( “index.php”, “index.html”,
> > 
> > > As it is now, I can get my  
> > > “check-local” =\> “disable”,  
> > > “check-local” =\> “disable”,  
> > > “port” =\> 10001,  
> > > )
> > > 
> > > * * *
> > 
> > WebMaster
> 
> * * *
> 
> Do You Yahoo!?  
> Tired of spam? Yahoo! Mail has the best spam protection around  
> [http://mail.yahoo.com](http://mail.yahoo.com)
> 
> * * *
> 
> Rails mailing list  
> removed\_email\_address@domain.invalid  
> [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

-Ezra Z.  
WebMaster  
Yakima Herald-Republic Newspaper  
removed\_email\_address@domain.invalid  
509-577-7732
