【问题标题】:Ruby on Rails user generated subdomains - do I need a Dedicated Virtual Host?Ruby on Rails 用户生成的子域 - 我需要专用虚拟主机吗?
【发布时间】:2011-01-17 04:17:13
【问题描述】:

Robby on Rails 所述,我已在我的 mac OSX 上成功运行子域。我想遵循下面的示例代码,但我不知道从哪里开始。如何编辑 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

【问题讨论】:

    标签: ruby-on-rails dns subdomain virtualhost


    【解决方案1】:

    我用 Heroku 做了类似的事情,它支持通配符 DNS,绝对值得一看。有多种处理 DNS 的选项 - 大多数情况下,这实际上是由管理您的名称服务器的人处理的。

    Dreamhost 将根据请求允许通配符 DNS 托管......基本上,他们使用其名称服务器处理传入请求的映射,因此除了发送电子邮件之外您无需做太多事情。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-04-26
      • 2015-06-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-12
      • 2015-05-27
      • 2012-12-27
      相关资源
      最近更新 更多