Rails 应用程序中的自定义域
我希望我的服务的用户能够添加他们自己的自定义域.例如,www.[their domain].com
应该能够访问其应用程序的索引并显示页面.我的服务是在 Rails 3 中实现的.
I want users of my service to be able to add their own custom domains. For example, www.[their domain].com
should be able to access their application's index and show pages. My service is implemented in Rails 3.
我见过像 Tumblr 这样的应用为其前端博客提供此功能.尽管我已经看到 Rails 应用以 Basecamp 的方式实现子域,但我还没有找到完全自定义域的资源.
I've seen apps like Tumblr offer this functionality for their front facing blogs. Although I have seen apps for Rails that implement sub domains in the way that Basecamp does, I have not found a resource for fully custom domains.
他们需要在他们的 DNS 中创建一个 A 记录来指向你的应用服务器 IP.您需要知道他们指向您的服务器的域并将其记录到他们的帐户中,还需要设置您的网络服务器配置,以便将来自其他域的请求引导到您的应用程序.然后,您可以使用请求对象在您的 application_controller 中查找他们的帐户.
They'll need to create an A record in their DNS to point to your app servers IP. You'll need to know what domain they have pointed to your server and log it against their account, and also set your web servers config in such a way as to channel the requests from other domains to your app. You can then use the request object to look up their account in your application_controller.