これは私にとっては開発モードで動作しますが、乗客を使ってレールアプリを展開しようとすると、コントローラが呼び出されていないように見えます。Rail ControllerをPassenger経由でサブドメインと連携させるにはどうすればよいですか?
www.example.comへのAPIのcnameレコードを設定しました。また、私はRails 3.2とRuby 1.9.3を使用しています。
ここに私のroutes.rb
ファイルの関連部分があります。
# PassengerHighPerformance on
PassengerMaxPoolSize 12
PassengerPoolIdleTime 1500
# PassengerMaxRequests 1000
PassengerStatThrottleRate 120
# RackAutoDetect Off
# RailsAutoDetect Off
NameVirtualHost 10.28.124.130:80
<VirtualHost 10.28.124.130:80>
ServerName application.example.com
ServerAlias application
DocumentRoot /var/www/application/current/public/
<Directory /var/www/application/current/public>
Options +FollowSymLinks
AllowOverride All
Order allow,deny
allow from all
</Directory>
RackBaseURI/
RackEnv staging
ErrorDocument 503 /system/maintenance.html
RewriteEngine On
RewriteLog /var/www/application/current/log/rewrite_log
RewriteLogLevel 9
RewriteCond %{REQUEST_URI} !.(css|gif|jpg|png)$
RewriteCond %{DOCUMENT_ROOT}/system/maintenance.html -f
RewriteCond %{SCRIPT_FILENAME} !maintenance.html
RewriteRule ^.*$ - [redirect=503,last]
</VirtualHost>
<VirtualHost 10.28.124.130:80>
ServerName api.application.example.com
ServerAlias api.application
DocumentRoot /var/www/application-api/current/public
<Directory /var/www/application-api/current/public>
Options +FollowSymLinks
AllowOverride All
Order allow,deny
allow from all
</Directory>
RackBaseURI/
RackEnv staging
</VirtualHost>
これはちょうど私が私のAPIを説明書いたいくつかのドキュメントをレンダリング:
# API
constraints :subdomain => 'api' do
scope :module => 'api' do #:constraints => { :format => :json } do
match '*skippydoo' => redirect('/'), :format => :html
root :to => 'pages#developer', :format => :html
end
end
は、ここでApacheの設定です。
ドキュメントルートを空のディレクトリに切り替えてレンダリングすることができるので、Apacheが正しく動作していることが分かります。 application-api
ディレクトリは、配備されたアプリケーションへのシンボリックリンクです。
マイAPIコントローラが$RAILS_ROOT/app/controllers/api/pages_controller.rb
に住んでいるが、実際に仕事をしているものがそう$RAILS_ROOT/app/controllers/pages_controller.rb
Started GET "/" for 10.29.28.157 at 2012-04-26 21:12:51 -0500
Processing by PagesController#home as HTML
Rendered pages/home.html.erb within layouts/application (283.7ms)
Rendered layouts/_stylesheets.html.erb (4.4ms)
Rendered layouts/_header.html.erb (5.7ms)
Rendered layouts/_footer.html.erb (0.4ms)
Completed 200 OK in 522ms (Views: 394.4ms | ActiveRecord: 12.1ms | Solr: 0.0ms)
で、何が与えますか?なぜそれは開発ではなく生産では機能していますか?
仮想ホストは、apiサブドメインの2番目のVirtualHostブロックです。 'www'サブドメインはありません – gaahrdner
私は参照してください。私はあなたの "www.example.com"リファレンスに混乱していました。刺し具合は:サブドメインの制約を "api.application"に変更します。 ActionDispatch :: Http :: URL.subdomainを見ると、両方が返されることがわかります。 –
ああ、それはうまくいきませんでした。しかし、あなたは正しい道を私に決めました! – gaahrdner