# Localhost subdomains with Mongrel on OSX

**URL:** <https://www.ruby-forum.com/t/localhost-subdomains-with-mongrel-on-osx/74088>\
**Category:** Rails\
**Created:** [October 29, 2006, 11:14pm UTC](https://www.ruby-forum.com/t/localhost-subdomains-with-mongrel-on-osx/74088 "2006-10-29T23:14:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![blinking\_bear](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/a9a28c/32.png) [@blinking\_bear](https://www.ruby-forum.com/u/blinking_bear)\
**Post date:** [October 29, 2006, 11:14pm UTC](https://www.ruby-forum.com/t/localhost-subdomains-with-mongrel-on-osx/74088/1 "2006-10-29T23:14:00Z")

</div>

I’m writing a rails app that will use subdomains ala basecamp and  
tadalist,  
so that users will be organized into [groupname.foo.com](http://groupname.foo.com). I’m kind of  
new to  
unix so I’m trying to figure out how to handle subdomains locally with  
mongrel. Obvioiusly going to somesubdomain.localhost:3000 doesn’t work.  
I’ve hacked the /etc/hosts file to setup a local test url: 127.0.0.1  
[www.localsite.com](http://www.localsite.com). I can use that to run locally and pick up subdomains  
but  
it feels like there has to be a better way. Any suggestions?

Also, in the etc/hosts file the \* wildcard doesn’t seem to catch all  
subdomain s (ie. \*.localsite.com)

Thanks

---

<div class="post-metadata">

**Author:** ![blinking\_bear](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/a9a28c/32.png) [@blinking\_bear](https://www.ruby-forum.com/u/blinking_bear)\
**Post date:** [October 29, 2006, 11:32pm UTC](https://www.ruby-forum.com/t/localhost-subdomains-with-mongrel-on-osx/74088/2 "2006-10-29T23:32:03Z")

</div>

On Oct 29, 2006, at 2:11 PM, blinking bear wrote:

> all subdomain s (ie. \*.localsite.com)
> 
> Thanks

```
I'm sure there must be a better way on OSX but I don't know what it

```

is. When I need to dev local apps that use subdomains I just setup  
some etc/hosts aliases and use those:

127.0.0.1 [localhost.com](http://localhost.com) [engineyard.localhost.com](http://engineyard.localhost.com)  
[ezmobius.localhost.com](http://ezmobius.localhost.com) [demo.localhost.com](http://demo.localhost.com)

cheers-  
– Ezra Z.  
– Lead Rails Evangelist  
– removed\_email\_address@domain.invalid  
– Engine Y., Serious Rails Hosting  
– (866) 518-YARD (9273)

---

<div class="post-metadata">

**Author:** ![blinking\_bear](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/a9a28c/32.png) [@blinking\_bear](https://www.ruby-forum.com/u/blinking_bear)\
**Post date:** [October 30, 2006, 2:21am UTC](https://www.ruby-forum.com/t/localhost-subdomains-with-mongrel-on-osx/74088/3 "2006-10-30T02:21:15Z")

</div>

> I’ve hacked the /etc/hosts file to setup a local test url: 127.0.0.1  
> [www.localsite.com](http://www.localsite.com). I can use that to run locally and pick up subdomains  
> but  
> it feels like there has to be a better way. Any suggestions?

This might help:  
[http://www.evolt.org/article/Enabling\_Virtual\_Hosts\_on\_MacOS\_X/18/13138/index.html](http://www.evolt.org/article/Enabling_Virtual_Hosts_on_MacOS_X/18/13138/index.html)

Cheers!  
=victor.grey

---

<div class="post-metadata">

**Author:** ![blinking\_bear](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/a9a28c/32.png) [@blinking\_bear](https://www.ruby-forum.com/u/blinking_bear)\
**Post date:** [November 7, 2006, 10:43am UTC](https://www.ruby-forum.com/t/localhost-subdomains-with-mongrel-on-osx/74088/4 "2006-11-07T10:43:58Z")

</div>

Agreed that I haven’t found a way to do the \* domains either – what  
is nice on OSX, however is editing the /etc/hosts file and then  
running lookupd -flushcache to flush the dns cache so that it looks up  
(and finds your /etc/hosts file) everytime.

We wrote an article on cleanair about subdomain auth and how to test:

[http://cleanair.highgroove.com/articles/2006/08/14/simplied-subdomain-authentication-in-ruby-on-rails](http://cleanair.highgroove.com/articles/2006/08/14/simplied-subdomain-authentication-in-ruby-on-rails)

let us know if you find anything.

On 10/29/06, Ezra Z. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > I can use that to run locally and pick up subdomains but it feels  
> > some etc/hosts aliases and use those:  
> > – (866) 518-YARD (9273)
> 
> >

–  
Charles Brian Q.  
self-promotion: [www.seebq.com](http://www.seebq.com)  
highgroove studios: [www.highgroove.com](http://www.highgroove.com)  
slingshot hosting: [www.slingshothosting.com](http://www.slingshothosting.com)
