# Rails running as sub domain: Help please

**URL:** <https://www.ruby-forum.com/t/rails-running-as-sub-domain-help-please/75603>\
**Category:** Rails\
**Created:** [November 11, 2006, 12:05pm UTC](https://www.ruby-forum.com/t/rails-running-as-sub-domain-help-please/75603 "2006-11-11T12:05:02Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![zanoni](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/e99b99/32.png) [@zanoni](https://www.ruby-forum.com/u/zanoni)\
**Post date:** [November 11, 2006, 12:05pm UTC](https://www.ruby-forum.com/t/rails-running-as-sub-domain-help-please/75603/1 "2006-11-11T12:05:02Z")

</div>

I need to set up Rails as a sub-domain to another application. Are  
there  
any steps I need to take. Not sure how to get started.  
Please help

TIA  
Stuart

–

> **[Dark ambient](https://en.wikipedia.org/wiki/Dark_ambient)**
>
> Dark ambient (referred to as ambient industrial especially in the 1980s) is a genre of post-industrial music that features an ominous, dark droning and often gloomy, monumental or catacombal atmosphere, partially with discordant overtones. It shows similarities with ambient music, a genre that has been cited as a main influence by many dark ambient artists, both conceptually and compositionally. Although mostly electronically generated, dark ambient also includes the sampling of hand-pla 
> The te...

---

<div class="post-metadata">

**Author:** ![zanoni](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/e99b99/32.png) [@zanoni](https://www.ruby-forum.com/u/zanoni)\
**Post date:** [November 11, 2006, 12:23pm UTC](https://www.ruby-forum.com/t/rails-running-as-sub-domain-help-please/75603/2 "2006-11-11T12:23:04Z")

</div>

i did not really workt with subdomain in rails. Why do you need actualy  
a subdomain?  
If you are working with more rails applications you could start it on  
the same server using diffrent ports.

I don’t know if this was the answer to your question. Is that what you  
ment?

---

<div class="post-metadata">

**Author:** ![zanoni](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/e99b99/32.png) [@zanoni](https://www.ruby-forum.com/u/zanoni)\
**Post date:** [November 11, 2006, 12:33pm UTC](https://www.ruby-forum.com/t/rails-running-as-sub-domain-help-please/75603/3 "2006-11-11T12:33:05Z")

</div>

Handling subdomains or other protocols (e.g. https) in rails isn’t  
unsophisticated at all. But Dan W. recently released a rails plugin  
called «request routing» to simplify these solutions.

To install the plugin type the following command:

ruby script/plugin install  
[http://svn.vivabit.net/external/rubylibs/request\_routing](http://svn.vivabit.net/external/rubylibs/request_routing)

The properties to differentiate are listed below:  
-subdomain  
-domain  
-method  
-port  
-remote\_ip  
-content\_type  
-accepts  
-request\_uri  
-protocol

i found this post on a forum

---

<div class="post-metadata">

**Author:** ![zanoni](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/e99b99/32.png) [@zanoni](https://www.ruby-forum.com/u/zanoni)\
**Post date:** [November 11, 2006, 12:43pm UTC](https://www.ruby-forum.com/t/rails-running-as-sub-domain-help-please/75603/4 "2006-11-11T12:43:06Z")

</div>

Tux, thank you. I did look at Dan’s plugin and I believe it will help.  
The reason why I need Rails as a subdomain, is that another application  
(non  
Rails) is the front end (so to speak).  
However Rails is doing all of the database work.  
So, spcifically, what I think I’m lacking on in knowledge -  
1- Does Rails sit in a subdirectory of the main app, like a subdomain  
typically would ?  
2- Any special configurations for Rails ?  
3- How about the app that will be making the calls, do I need some kind  
of  
redirects or just making the call to the subdomain should be  
enough ?

TIA  
Stuart

On 11/11/06, tux [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> i found this post on a forum
> 
> >

–

> **[Dark ambient](https://en.wikipedia.org/wiki/Dark_ambient)**
>
> Dark ambient (referred to as ambient industrial especially in the 1980s) is a genre of post-industrial music that features an ominous, dark droning and often gloomy, monumental or catacombal atmosphere, partially with discordant overtones. It shows similarities with ambient music, a genre that has been cited as a main influence by many dark ambient artists, both conceptually and compositionally. Although mostly electronically generated, dark ambient also includes the sampling of hand-pla 
> The te...

---

<div class="post-metadata">

**Author:** ![zanoni](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/e99b99/32.png) [@zanoni](https://www.ruby-forum.com/u/zanoni)\
**Post date:** [November 11, 2006, 6:42pm UTC](https://www.ruby-forum.com/t/rails-running-as-sub-domain-help-please/75603/5 "2006-11-11T18:42:08Z")

</div>

If all you are trying to do is make:

[www.foo.com](http://www.foo.com) =\> your first app  
[bar.foo.com](http://bar.foo.com) =\> your second app

You have several choices. If your first app is PHP (which I believe you  
said  
it was), then let Apache serve it directly using mod\_php, and proxy a  
port  
to your Rails app on a different port. Then set up Mongrel or Lighty to  
listen on that second port.

If they are both Rails apps, it’s a snap: Use Pound to resolve the  
subdomains and proxy them to Mongrel packs running on different ports.

HTH

Dark A. wrote:

> >

–  
View this message in context:  
[http://www.nabble.com/-Rails--Rails-running-as-sub-domain%3A-Help-please-tf2612550.html#a7294860](http://www.nabble.com/-Rails--Rails-running-as-sub-domain%3A-Help-please-tf2612550.html#a7294860)  
Sent from the RubyOnRails Users mailing list archive at [Nabble.com](http://Nabble.com).

---

<div class="post-metadata">

**Author:** ![zanoni](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/e99b99/32.png) [@zanoni](https://www.ruby-forum.com/u/zanoni)\
**Post date:** [November 11, 2006, 7:34pm UTC](https://www.ruby-forum.com/t/rails-running-as-sub-domain-help-please/75603/6 "2006-11-11T19:34:16Z")

</div>

On 11/11/06, s.ross [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> it was), then let Apache serve it directly using mod\_php, and proxy a port  
> to your Rails app on a different port. Then set up Mongrel or Lighty to  
> listen on that second port.

Excellent, great information, very much appreciated.

If they are both Rails apps, it’s a snap: Use Pound to resolve the

> subdomains and proxy them to Mongrel packs running on different ports.

I wish it was just Rails, but good information as well. There is much  
better  
information around on multiple Rails apps , then Rails + some other  
language.  
I saw the Pound stuff up on the wiki.

Stuart
