2011-11-14 9 views
8

私はRails 3.1、UnicornとApacheのセットアップをしています。 Apacheの設定は以下の通りで、production.rbはthisのようになります。私はh264ストリーミングを好きですが、Railsがこれらのビデオファイルを提供しているので、Apache Modは動作しません。Rails 3.1、Unicorn and Apache:静的ファイル

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の設定に何か問題があります。ちょうどあなたのproduction.rbコードから

答えて

19

私はこの問題のpostを持っている(ええ、それはまた、私に起こった)、それに役立つことを願っています。それはあなたのRewrite Rule

はここに私のApacheサーバの設定で上書きしてしまうため

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

<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> 
+0

これは、ありがとう! btw。記事リンクがlocalhostを指しています。 – jiriki

+0

私はリンクを修正しました、ありがとうございます! – Manic

+1

完璧な、完全に理にかなっている、すべてのガイドは、私はレール3 + Apacheの+ユニコン/薄い持って、この問題が見つかりました – Rob

0

:、「X-sendfileの」ヘッダと行のコメントを解除し、あなたのユニコーンのプールを再起動して、もう一度試して

# 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 

してみてください。

+0

おかげで、これは助けにはなりませんでした。 – jiriki

関連する問題