8

Rails 3.1、Unicorn、Apacheのセットアップがあります。私のApache設定は以下のとおりで、production.rbは次のようになります。私はh264ストリーミングを使用するのが好きですが、Railsがこれらのビデオファイルを提供しているため、ApacheModは機能しません。

DocumentRoot /blabla/current/public

RewriteEngine On
Options FollowSymLinks

<Proxy balancer://unicornservers>
  BalancerMember http://127.0.0.1:4000
</Proxy>

# Redirect all non-static requests to rails
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
RewriteRule ^/(.*)$ balancer://unicornservers%{REQUEST_URI} [P,QSA,L]

ProxyPass / balancer://unicornservers/
ProxyPassReverse / balancer://unicornservers/
ProxyPreserveHost on

<Proxy *>
 Order deny,allow
 Allow from all
</Proxy>

XSendFile On
XSendFileAllowAbove on

serve_static_assetsを有効にする必要があります。そうしないと、静的なものをダウンロードできません。私もアセットをプリコンパイルしましたが、Rails(Rackだと思います)がサービスを提供していない限り、パブリックディレクトリからファイルを利用できないため、違いはありません。

config.action_controller.asset_hostを使用する必要がありますか、それともApacheの構成に問題がありますか。

4

2 に答える 2

19

私はこの問題についての投稿を持っています(ええ、それは私にも起こりました)、それが役立つことを願っています。

重要な点は、ProxyPass / balancer://unicornservers/パターンを削除することです。Rewrite Rule

これが私のApacheサーバーの設定です。

<VirtualHost *:80>

  ServerName example.org
  DocumentRoot /dir/of/your/project

  RewriteEngine On

  # Redirect all non-static requests to unicorn
  RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
  RewriteRule ^/(.*)$ balancer://unicornservers%{REQUEST_URI} [P,QSA,L]

  <Proxy balancer://unicornservers>
    BalancerMember http://127.0.0.1:2007
  </Proxy>

</VirtualHost>
于 2012-02-22T09:37:03.577 に答える
0

あなたのproduction.rbコードから:

# Specifies the header that your server uses for sending files
# config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx

'X-Sendfile'ヘッダーのある行のコメントを解除し、Unicornのプールを再起動して、再試行してください。

于 2011-11-14T01:13:31.907 に答える