Ruby on Rails 用户生成的子域 - 我需要专用虚拟主机吗?
我已成功在我的 mac OSX 上运行子域,如 Robby on Rails。我想遵循下面的示例代码,但我不知道从哪里开始。如何编辑 DNS 设置?我需要有专用的虚拟主机来执行此操作吗?现在我有一个标准的(蹩脚的)Dreamhost 共享主机。如果我选择 DVH,Media Temple 是一个不错的选择吗?
任何媒体建议都会有所帮助 - 我的谷歌搜索只会导致愤怒的客户/托管公司的长篇大论。
谢谢!
# 1) Point *.example.com in your DNS setup to your server.
#
# 2) Setup an Apache vhost to catch the star pointer:
#
# <VirtualHost *:80>
# ServerName example.com
# ServerAlias *.example.com
# </VirtualHost>
#
# 3) Set the current account from the subdomain
class ApplicationController < ActionController::Base
before_filter :set_current_account
private
def set_current_account
@current_account = Account.find_by_subdomain!(request.subdomains.first)
end
end
# 4) Tie all top-level requests off the current account
class CustomersController < ApplicationController
def index
@customers = @current_account.customers
end
end
I'm successfully running subdomains on my mac OSX as outlined by Robby on Rails. I'd like to follow the example code below but I have no idea where to start. How do you edit a DNS setup? Do I need to have a dedicated virtual host to do this? Right now I have a standard (crappy) Dreamhost shared hosting. If I go with a DVH, is Media Temple a good pick?
Any media recs would be helpful - my google search's have only resulted in angry customer/hosting company tirades.
Thanks!
# 1) Point *.example.com in your DNS setup to your server.
#
# 2) Setup an Apache vhost to catch the star pointer:
#
# <VirtualHost *:80>
# ServerName example.com
# ServerAlias *.example.com
# </VirtualHost>
#
# 3) Set the current account from the subdomain
class ApplicationController < ActionController::Base
before_filter :set_current_account
private
def set_current_account
@current_account = Account.find_by_subdomain!(request.subdomains.first)
end
end
# 4) Tie all top-level requests off the current account
class CustomersController < ApplicationController
def index
@customers = @current_account.customers
end
end
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我用 Heroku 做了类似的事情,它支持通配符 DNS,绝对值得一看。有多种处理 DNS 的选项 - 大多数情况下,这实际上是由管理您的名称服务器的人处理的。
Dreamhost 将允许根据请求托管通配符 DNS...基本上,他们使用名称服务器处理映射传入请求,因此除了发送电子邮件之外,您无需做太多事情。
I do something similar with Heroku, which supports Wildcard DNS, definitely worth a look. There are a range of options for handling the DNS - most of the time this is actually handled by whoever is managing your name servers.
Dreamhost will allow Wildcard DNS hosting on request ... basically, they handle mapping incoming requests using their name servers, so not much for you to do other than send an email.