开发者

How to offer custom domains for my Saas app in heroku?

I want to offer custom domains for my clients in heroku.

Having my domain, www.xpto.com, and my users domains, user1.xpto.com, user2.xpto.com, I want to give them the possibility to add a CNAME record pointing to my app. A custom domain www.user1xpto.com pointing to user1.xpto.com.

How ca开发者_Go百科n I achieve this with Heroku?

Thanks,


If you add one of the custom domain add-ons to your app, you should be able to do this using the Heroku gem.

class CustomDomain < ActiveRecord::Base
    belongs_to :user
    after_create :setup_at_heroku
    def setup_at_heroku
       # make calls with heroku gem here
       test_cname_later
    end
    def test_cname_later
      # use background job here to try to call custom.com/custom_domains/activate
    end
end

Setup an action to /custom_domains/activate that looks up the domain from the request and sets it to active.


You can do this pretty well without using the Heroku gem, by using the Heroku REST API to add domains as your users configure them to use.


The Heroku API supports custom domain names. See: https://devcenter.heroku.com/articles/custom-domains


You can have wildcard custom domains with the wildcard domains addon but if you want the user to be able to use their own domain you will have to use the heroku gem inside your app to add the domain to your applications custom domains.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜