如何在heroku中为我的Saas应用程序提供自定义域名?

ode*_*dew 5 dns ruby-on-rails heroku

我想在heroku中为我的客户提供自定义域名.

拥有我的域名www.xpto.com和我的用户域user1.xpto.com,user2.xpto.com,我想让他们可以添加指向我的应用程序的CNAME记录.定制域名www.user1xpto.com,指向user1.xpto.com.

如何使用Heroku实现这一目标?

谢谢,

Jor*_*dan 5

如果您将一个自定义域加载项添加到您的应用程序,您应该能够使用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
Run Code Online (Sandbox Code Playgroud)

将操作设置为/ custom_domains/activate,从请求中查找域并将其设置为活动状态.