Ruby on Rails ユーザーが生成したサブドメイン - 専用仮想ホストが必要ですか?
-
20-09-2019 - |
質問
で概説されているように、Mac OSX でサブドメインを正常に実行しています。 ロビー・オン・レールズ. 。以下のサンプルコードに従いたいのですが、どこから始めればよいのかわかりません。DNS 設定を編集するにはどうすればよいですか?これを行うには専用の仮想ホストが必要ですか?現在、私は標準の(粗末な)Dreamhost 共有ホスティングを使用しています。DVH を使用する場合、Media Temple が適していますか?
メディアに関する情報は何でも役に立ちます。私の Google 検索では、顧客やホスティング会社が怒って暴言を吐く結果しか得られませんでした。
ありがとう!
# 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
解決
ワイルドカード DNS をサポートする Heroku でも同様のことを行っていますが、一見の価値があります。DNS の処理にはさまざまなオプションがあります。ほとんどの場合、これはネーム サーバーを管理している人によって実際に処理されます。
Dreamhost は、リクエストに応じてワイルドカード DNS ホスティングを許可します...基本的に、これらはネームサーバーを使用して受信リクエストのマッピングを処理するため、電子メールを送信する以外に行うことはあまりありません。
所属していません StackOverflow