Human Dunnil
2006-Apr-16 23:22 UTC
[Rails] Multiple domain name, One Rails application, is this possible?
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 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060416/12ffbb8c/attachment.html
Dean Wampler
2006-Apr-16 23:35 UTC
[Rails] Multiple domain name, One Rails application, is this possible?
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 On 4/16/06, Human Dunnil <h.dunnil@gmail.com> wrote:> 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 > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >
Grant Neufeld
2006-Apr-17 06:22 UTC
[Rails] Multiple domain name, One Rails application, is this possible?
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.)
Ray Baxter
2006-Apr-17 06:41 UTC
[Rails] Re: Multiple domain name, One Rails application, is this possible?
Grant Neufeld wrote:> 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:I don''t have to do any of these extra steps on Mac OS X 10.4.6.> sudo niload -v hosts . < /etc/hostsAccording 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
Christian Klauser
2006-Apr-17 11:08 UTC
[Rails] Re: Multiple domain name, One Rails application, is this p
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. -- Posted via http://www.ruby-forum.com/.
Adrian Liem
2007-Apr-13 13:23 UTC
Re: Multiple domain name, One Rails application, is this pos
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 -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
gene.tani-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Apr-13 13:39 UTC
Re: Multiple domain name, One Rails application, is this pos
On Apr 13, 6:23 am, Adrian Liem <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Hi, I''m newbie and facing this situation too. I have several questions: > > 1. canwww.a.comandwww.b.compoint to the same > [app]/controller/application.rb ? > > 2. canwww.a.com/another/controllerandwww.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 > > -- > Posted viahttp://www.ruby-forum.com/.google for subdomains and account keys: http://cleanair.highgroove.com/articles/2006/08/14/simplied-subdomain-authentication-in-ruby-on-rails http://wiki.rubyonrails.com/rails/pages/HowToUseSubdomainsAsAccountKeys http://dev.rubyonrails.org/svn/rails/plugins/account_location/README --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Adrian Liem
2007-Apr-13 14:49 UTC
Re: Multiple domain name, One Rails application, is this pos
gene.tani-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:> google for subdomains and account keys: > http://cleanair.highgroove.com/articles/2006/08/14/simplied-subdomain-authentication-in-ruby-on-rails > http://wiki.rubyonrails.com/rails/pages/HowToUseSubdomainsAsAccountKeys > > http://dev.rubyonrails.org/svn/rails/plugins/account_location/READMEthanks 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 -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Peter De Berdt
2007-Apr-13 20:33 UTC
Re: Multiple domain name, One Rails application, is this pos
On 13 Apr 2007, at 16:49, Adrian Liem wrote:> 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,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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Adrian Liem
2007-Apr-13 23:51 UTC
Re: Multiple domain name, One Rails application, is this pos
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-- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Peter De Berdt
2007-Apr-14 08:47 UTC
Re: Multiple domain name, One Rails application, is this pos
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#serveraliasBest regards Peter De Berdt --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Russell Norris
2007-Apr-17 13:30 UTC
Re: Multiple domain name, One Rails application, is this pos
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 On 4/14/07, Peter De Berdt <peter.de.berdt-LPO8gxj9N8aZIoH1IeqzKA@public.gmane.org> wrote:> > 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 > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---