Allow users to CNAME to custom subdomain on Heroku App - ruby-on-rails

This may have been answered before (it seems relatively common) but for the life of me I cannot find it, so here we are.
I'm creating a relatively straightforward Ruby on Rails app and am (was?) planning on hosting it on Heroku since I'm already setup there.
The problem I'm having is that I'm creating a landing page builder that needs to allow users to view their website at something like https://their-app.my-app.com. Of course, there will be users who will also want to point their own domains (ex. their-app.com) to that subdomain via a CNAME.
1) Is it possible on Heroku to do that without having to add each one as a custom domain (which of course isn't realistic due to customers being able to add their own).
2) Any recommendations on which service might be the best for hosting this kind of setup? I really love the heroku PaaS setup but of course.. this is a requirement.
Side note: WHen doing it now (Creating a CNAME to point a domain name at the subdomain my app created) I currently get a Heroku page saying "No App Found at this Domain", etc.
Thanks!

Yes, this is doable and automatable on Heroku.
Using the Heroku Platform API, you can programmatically point domains to an app.
Then, your customer will have to point their domain to the value of the cname attribute provided by Heroku.

Related

How to do multi-tenant support with custom domains and SSL on Heroku

My app allows users to create custom product landing pages.
I wish to setup this scenario:
Pages can exist on brand.myapp.com/offer-name, however I want to enable users to create landing pages using their own domain, for example brand.customerdomain.com/offer-name, which serves a page from my app.
I am unsure about the best way to do this. I know I can have users point a CNAME record to 'myapp.com', and then I add 'brand.customerdomain.com' as a Heroku custom domain. But is there a limit to the amount of custom domains I can add to Heroku? There will be thousands of these domains, so I don't know if this solution is feasible. I have had some success with this approach, however I get SSL browser messages when accessing the page from the user's domain.
In terms of SSL, I have a wildcard certificate installed on Heroku, for *.myapp.com.
Another way is to have a proxy server hosted elsewhere, and have users point a CNAME to something like 'proxy.myapp.com', which routes to my Heroku URL, however I haven't been able to get this to work on Nginx (on DigitalOcean), and haven't found any suitable guides (I don't have much Nginx knowledge).
The proxy approach I found here - https://mrvautin.com/enabling-custom-domain-for-saas-application-on-heroku/.
Cloudflare has a solution for this problem, however it's available to enterprise customers only, so I'd prefer to have my own solution - https://www.cloudflare.com/saas/.
What would be the ideal way to have multi-tenancy, with custom domains and SSL on Heroku?

Correct approach to adding a wordpress site to an existing RoR site hosted on heroku

Hello I have an app developed for a client of mine. This app is hosted on heroku on domain http://www.mydomain.com. Client has limited technical knowledge and wants a system that will easily allow him to add/edit content on some sites. Example: customer wants to create a news page and edit it, or he wants to create a blog posts..... The customer does not want to edit the main pages that i have already created for the app. So i was thinking of adding a wordpress site under http://www.mydomain/com/extras and this will be a fully managed wordpress site that my client can edit himself. Is this the correct approach? i researched and apparently it is not easy to host worpress on heroku. your recommendation is highly appreciated
thanks
Buildpacks
If you want to install Wordpress on Heroku, you'll need to use a custom buildback (typically this Wordpress buildpack)
As for running in a buried folder, I suppose it would work if you had the system set up correctly - you may need to create a custom buildpack to handle it all.
Some info for you:-
When you git push heroku, Heroku’s slug compiler prepares your code
for execution by the Heroku dyno manager. At the heart of the slug
compiler is a collection of scripts called a buildpack.
What you'll be looking for is how to create a buildpack to help your application deploy correctly. If you put your Wordpress blog in the following Rails folder, it should be accessible at least (whether it will run is another matter, as the paths might be inconsistent):
/public/path/to/your/blog
This will give you the ability to access the blog from the following URL: domain.com/path/to/your/blog
--
DNS
Another way to achieve this would be to host your Rails app on heroku, whilst deploying the Wordpress site in some shared hosting.
You could then "route" a subdomain, or perhaps a deep folder, with your DNS setup on your host - allowing you to send the traffic to different hosts without the users noticing

Set up custom domains for users using rails 4, nginx with passenger

I have a rails application that uses subdomains to allow users to have their own seperate data in a CMS system. Basically a SaaS CMS system like wordpress.com or tumblr.com.
However i would like to give users the ability to choose their own domain (av alias for their subdomain). For example the user henrik.cmsdomain.com would like to have a custom domain that reads henrikswebsite.com.
How can i do this? Do i need to set up my own name servers? I'm not necessarily looking for complete answers, i just don't know where to start.
Im running on an ubuntu 13.10 digitalocean server with nginx, passenger, Rails 4 and postgresql (using schemas to seperate userdata).
What you're looking for is something called "virtual subdomains" (I think). Here is some information about how to set them up:
http://signalvnoise.com/posts/1512-how-to-do-basecamp-style-subdomains-in-rails
Rails Restful Routing and Subdomains
You basically need to set up a "wildcard" subdomain in your DNS (which will route all subdomain requests to your app), and let the routing middleware handle the request (& route accordingly)
Domains
Considering the updates, I have had a look online for you:
Rails routing to handle multiple domains on single application
I don't have experience of this directly, but I'd say you first need to get the domain to point to your site (with CNAME changes). This could then be caught by your routing middleware (as described in the link above), allowing you to "route" the request accordingly
Heroku does this exact thing - it's quite common

Heroku + Rails: How to allow my Users to add their own Custom Domains

All over the internet there are tons of posts about this, but no answers.
In my Rails app running on Heroku, can I allow my Users to add their own Custom Domains automatically? Does Heroku allow this?
Are there add-ons to help with this
By custom domains, I mean adding using their own top-level-domain,
not Subdomains. E.g., example.com
Here's one solution to allow this:
Set up a wildcard subdomain (for your app's domain) that points to your Heroku app.
Allow users to set a custom subdomain.
Users can then set up a CNAME (or ALIAS or ANAME, as described here) that points to their custom subdomain on your app.
Yep, it's definitely possible - you have to use the Heroku gem within your application and when they add domains you need to make an API call to add their chosen custom domain to your application.
If you want to be able to use SSL it won't work AFAIK because you can only have one SSL addon per app - however, subdomains are easier since you can do a wildcard subdomain and then it's also possible to use a wildcard SSL on your domain without having to involve making API calls and you then don't have to get your clients edit their DNS to point at your application.

Is it possible to have a site blog at mydomain.com and your heroku app at app.mydomain.com

I need to create the sales site for my application in wordpress as their themes are far more impressive than anything I could create in rails in a short time period. I need the rails app to be on a subdomain such as app.mydomain.com and Id prefer to host with heroku.
Is this possible and if so how?
If not what do other app providers do for their sales site and blog?
You might find your answer here: http://docs.heroku.com/custom-domains
The doc is good and the video explains how to customize your DNS. You'll be able to point your DNS wherever you want.
EDIT 1
Far more easier:
Go to your DNS provider
add a CNAME for app.mydomain.com
make it point to your Heroku's URL.

Resources