Forum: Ruby on Rails Multiple domain name, One Rails application, is this possibl

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
7595ff5e64d9a309c29932d106959973?d=identicon&s=25 Human Dunnil (Guest)
on 2006-04-17 01:24
(Received via mailing list)
Hello folks,
I'm new to the Rails framework and don't know where to look to find my
answer.

Here is the question, Is there a way to set multiple domain name for *a*
rails application, and base on the URL do the work in the app.
Imagine I have a user based document management system, each user want
to
access to her docs using her domain, but I don't like to have many rails
app
just for multiple domains, is there a way to show the users' docs base
on
the URL?

Any pointer to any book, article or direct answer is extremely
appreciated.

Thanks in advance,
Dunnil
F690ec04b0501b74b033fc64ff4f682b?d=identicon&s=25 Dean Wampler (Guest)
on 2006-04-17 01:36
(Received via mailing list)
Yes, I'm doing this with my sites (e.g., aspectprogramming.com and
links therein). My sites are all registered to go the same IP address
and my ApplicationController (application.rb) defines a
"before_filter" method that looks at the value of "request.host" to
determine which site the user is on.

A tricky bit is testing locally, e.g., "localhost:3000" obviously
isn't the same as "myvanitysite.com". To support this, you can add
some development hooks, like a special request parameter or
environment variable to force the one you want. Another possibility is
to define another configuration (in addition to the usual "test",
"production", etc.) A disadvantage of this approach is that you won't
be able to surf between "fake" domains, as only one will be supported
at a time.

By the way, I also run typo as a separate application. I handle this
through the lighttpd configuration, as described in numerous places on
the web.

Hope this helps.

dean


--
Dean Wampler
http://www.aspectassoc.com
http://www.aspectprogramming.com
http://www.contract4j.org
0cfd64ab75e1111c832a7f40b67d5143?d=identicon&s=25 Grant Neufeld (Guest)
on 2006-04-17 08:22
(Received via mailing list)
For testing purposes, you can 'fake' various domain names to point at
your local server. The domains can be real or fake domain names, and
all should be pointed at the "localhost" ip address (127.0.0.1).

On *nix & Mac OS X, edit the /etc/hosts file. E.g.:
127.0.0.1 my.example.tld
127.0.0.1 another.test.tld
127.0.0.1 etc.domain.tld

On Mac OS X, there are a couple extra steps. First, in the terminal,
run the command:
   sudo niload -v hosts . < /etc/hosts
That will copy the hosts into NetInfo.

You probably also need to add the hosts as 'machines' in NetInfo,
too. For each host:
  sudo niutil -create / /machines/my.example.tld
  sudo niutil -createprop / /machines/my.example.tld ip_address
127.0.0.1

With that, you'll be able to access a server running on your system
with any of the domain names you used.

Note that doing the above prevents you from accessing the actual
servers at those domains if they are real domains on other computers.
So, don't forget to roll that stuff back later!


To roll back:

Delete or comment-out the domains you added in the /etc/hosts file.

On Mac OS X, you can use the NetInfo Manager application
(/Applications/Utilities/NetInfo Manager) to delete the appropriate
entries from the "machines" directory. (Be sure to not mess with the
"localhost" entry, though.)
E28c35323f624b8b9ed8712e25105454?d=identicon&s=25 Ray Baxter (Guest)
on 2006-04-17 08:43
(Received via mailing list)
Grant Neufeld wrote:
> the command:
I don't have to do any of these extra steps on Mac OS X 10.4.6.

>   sudo niload -v hosts . < /etc/hosts

According to man niload

Most  processes  on  Mac  OS X access the information from the files in
/etc and from NetInfo indirectly through the  system  library  and  the
lookupd  daemon.   In some cases the files in /etc are consulted before
NetInfo, making it unnecessary to copy  information  from  these  files
into  NetInfo.   The  files  /etc/hosts,  /etc/networks, /etc/services,
/etc/protocols, and /etc/rpcs are consulted before NetInfo.


Editing /etc/hosts is much simpler. Rolling back is simpler also.

--

Ray
A1c4a0bb61649f18a4d65b1c7273a50f?d=identicon&s=25 Christian Klauser (sealedsun)
on 2006-04-17 13:08
If you want to do the same thing under Windows XP, run (Start -> Run)

    notepad C:\WINDOWS\system32\drivers\etc\hosts

The file you'll see works excatly like its *nix counterparts.
Dbdddaf7d6c8c998e8281908fea3e3bf?d=identicon&s=25 Adrian Liem (Guest)
on 2007-04-13 15:23
Hi, I'm newbie and facing this situation too. I have several questions:

1. can www.a.com and www.b.com point to the same
[app]/controller/application.rb ?

2. can www.a.com/another/controller and www.b.com/another/controller
point to the same [app]/controller/another/controller.rb ? or should
they point to [app]/controller/domain_controler/another/controller.rb ?

3. i'm a beginner in using cpanel. can this domain management thing be
done with cpanel? -- and which one should i use, the 'addon domain'
menu, or 'parked domain' menu?

thanks in advance

kind regards,

Adrian Liem
9dfe8c734b0f9b37a4e218425c0a2138?d=identicon&s=25 gene.tani@gmail.com (Guest)
on 2007-04-13 15:39
(Received via mailing list)
On Apr 13, 6:23 am, Adrian Liem <rails-mailing-l...@andreas-s.net>
wrote:
> done with cpanel? -- and which one should i use, the 'addon domain'
> menu, or 'parked domain' menu?
>
> thanks in advance
>
> kind regards,
>
> Adrian Liem
>
> --
> Posted viahttp://www.ruby-forum.com/.

google for subdomains and account keys:
http://cleanair.highgroove.com/articles/2006/08/14...
http://wiki.rubyonrails.com/rails/pages/HowToUseSu...

http://dev.rubyonrails.org/svn/rails/plugins/accou...
Dbdddaf7d6c8c998e8281908fea3e3bf?d=identicon&s=25 Adrian Liem (Guest)
on 2007-04-13 16:49
gene.tani@gmail.com wrote:
> google for subdomains and account keys:
> 
http://cleanair.highgroove.com/articles/2006/08/14...
> http://wiki.rubyonrails.com/rails/pages/HowToUseSu...
>
> http://dev.rubyonrails.org/svn/rails/plugins/accou...

thanks for your kind reply

I've successfully used SubdomainAsAccountKeys in my previous
application.
but it is not what I'm trying to do now

if SubdomainAsAccountKeys give the user a subdomain account, what I am
trying to do now is to give the user a domain account.

I've tried to google for this problem previously, and google lead me to
this page :)

enlighten me please,

Adrian Liem
00973881979aa0a660ffbbb2f7a907fb?d=identicon&s=25 Peter De Berdt (Guest)
on 2007-04-13 22:34
(Received via mailing list)
On 13 Apr 2007, at 16:49, Adrian Liem wrote:

>
> enlighten me please,

What you need to do if you want to host the same application on two
domain names, is put a ServerAlias in the Apache config file. That
way, both (or more than two) domain names will point to the same
application.

http://httpd.apache.org/docs/1.3/mod/core.html#serveralias


Best regards

Peter De Berdt
Dbdddaf7d6c8c998e8281908fea3e3bf?d=identicon&s=25 Adrian Liem (Guest)
on 2007-04-14 01:51
Thank you very much, that's just what I need.
I hope my webhost company will give me the access to apache's
ServerAlias :)

Peter De Berdt wrote:
> http://httpd.apache.org/docs/1.3/mod/core.html#serveralias
00973881979aa0a660ffbbb2f7a907fb?d=identicon&s=25 Peter De Berdt (Guest)
on 2007-04-14 10:48
(Received via mailing list)
Chances are that the add-on domain option in cpanel actually adds
this line to the apache config file.

On 14 Apr 2007, at 01:51, Adrian Liem wrote:

> Thank you very much, that's just what I need.
> I hope my webhost company will give me the access to apache's
> ServerAlias :)
>
> Peter De Berdt wrote:
>> http://httpd.apache.org/docs/1.3/mod/core.html#serveralias



Best regards

Peter De Berdt
5030981121b21bed8aee074f68bd5074?d=identicon&s=25 Russell Norris (Guest)
on 2007-04-17 15:32
(Received via mailing list)
You might also want to look at any options on there concerning
"mirroring".
I'm currently using such a setup to serve multiple sites out of one app.

RSL
This topic is locked and can not be replied to.