Multiple domains running on a single rails application

I am creating a blogging application in which we allow our customers to use their own custom domain names, such as domainexample.com, so each other domain serves the same application, but with different content.

However, I am struggling to figure out how to configure this on a production server. If my production server has a static IP address, then I can accurately set the a-record in each domain on the ip of the production server.

But what if the production server does not have a static IP. For example, if we want to place it on a hero or typewriter? I have seen several solutions on the Internet that require the use of rewriting rules, but they require server reboots and cannot really dynamically add and remove new domains when registering new users. Does anyone know of any good solutions that allow multiple domains to fall into the same rails application?

+8
ruby-on-rails apache ruby-on-rails-3 hosting
source share
1 answer

Geroku is not the only option. If you can anticipate your client domains, take a look. If you cannot, Rails routes constraints , and a combination of the accepted answer to the question above should get you where you need to get together. It seems that you do not want to restart your server, so do not edit the routes. You can also make domains part of your models or differ at the controller level or use URL rewriting at the web server level.

The problem, as I see it, is that Rails violates its mantra of opinions about the configuration here. There are many ways to service from multiple domains. This can be inherent complexity, but the Rails manual can at least document one possible solution.

+3
source share

All Articles