我正在创建像 Shopify 这样的多租户应用程序,并且想知道如何在指向同一应用程序实例的服务器上创建自定义域?
例如:
app1.mysystem.com == www.mystore.com
app2.mystem.com == www.killerstore.com
我需要像 Google Apps 那样在 CNAME 上进行该配置吗?如果是这样,我该怎么做?有没有一些好的论文展示了它是如何工作的?
PS:app1和app2指向同一个应用程序!
谢谢
我有类似的设置并且正在使用 nginX。为了便于维护,我所做的就是接受来自 nginx 的所有连接,并在我的应用程序中进行过滤。
# application_controller.rb
before_filter :current_client
private
def current_client
# I am using MongoDB with Mongoid, so change the syntax of query accordingly
@current_client ||= Client.where(:host => request.host).first
render('/public/404.html', :status => :not_found, :layout => false) unless @current_client
end
您可以让您的客户拥有一个域记录,其中的域/子域指向you_ip
or your_domain_pointing_to_your_ip.com
并将其捕获在表单中并保存在数据库中。然后更改查询current_client
like:
@current_client ||= Client.or(:host => request.host).or(:alias => request.host).first
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)