Creating virtual hosts with Mongrel?


#1

Does anyone know how to use Mongrel to create virtual hosts? My
production site will have all kinds of domains pointing to it, and I
also need to figure out how to do subdomains. Rails should react to
the host name, doing a lookup based on the name and pull different
records from the database based on this.

For example, I’d like www.mysite.com to point back to 127.0.0.1:3000,
and the same for username.productionsite.com.

I’m using OS X Leopard

Any references or council will be appreciated, thanks in advance!

groove


#2

You might consider switching to Passenger for stuff like this. This is
how our team is tackling this without much effort. Takes just a few
minutes to setup/switch. Here is a writeup on it (for OS X).

http://www.robbyonrails.com/articles/2009/02/11/switch-to-passenger-mod_rails-in-development-on-osx-in-less-than-7-minutes-or-your-money-back

Cheers,
Robby

On Thu, Feb 19, 2009 at 11:02 AM, groovetrain removed_email_address@domain.invalid
wrote:

I’m using OS X Leopard

Any references or council will be appreciated, thanks in advance!

groove


Robby R.
Chief Evangelist, Partner

PLANET ARGON, LLC
design // development // hosting w/Ruby on Rails

http://planetargon.com/
http://robbyonrails.com/
http://twitter.com/planetargon
aim: planetargon

+1 503 445 2457
+1 877 55 ARGON [toll free]
+1 815 642 4068 [fax]


#3

On 19 Feb 2009, at 19:02, groovetrain wrote:

Does anyone know how to use Mongrel to create virtual hosts? My
production site will have all kinds of domains pointing to it, and I
also need to figure out how to do subdomains. Rails should react to
the host name, doing a lookup based on the name and pull different
records from the database based on this.

Typically people use nginx, apache etc… to handle the nuts and bolts
side of virtual hosts. There’s railscasts on using subdomains
(http://railscasts.com/episodes/123-subdomains
)

Fred


#4

Mongrel will respond to everything with the same app. The app, however
has access to A request.env variable which has hostname in it. Inspect
it to find out more.

Blog: http://random8.zenunit.com/
Learn rails: http://sensei.zenunit.com/


#5

Both of these are very helpful, thank you both so much.

Does passenger allow for full domain names? Kindof like pseudo-hosts,
like having a full www.alskdfjhdsaf.com pointed back to localhost:
3000?

Is there some way of doing this by hacking the /etc/hosts file?

Groove

On Feb 19, 2:15 pm, Frederick C. removed_email_address@domain.invalid


#6

Groove,

Did you read my article? We do the following for subdomains as well.

http://www.robbyonrails.com/articles/2009/01/11/subdomain-accounts-with-ruby-on-rails-explained

Cheers,
Robby

On Thu, Feb 19, 2009 at 11:59 AM, groovetrain removed_email_address@domain.invalid
wrote:

records from the database based on this.
and the same for username.productionsite.com.

I’m using OS X Leopard

Any references or council will be appreciated, thanks in advance!

groove


Robby R.
Chief Evangelist, Partner

PLANET ARGON, LLC
design // development // hosting w/Ruby on Rails

http://planetargon.com/
http://robbyonrails.com/
http://twitter.com/planetargon
aim: planetargon

+1 503 445 2457
+1 877 55 ARGON [toll free]
+1 815 642 4068 [fax]