2011-11-14 3 views
8

나는 Rails 3.1, Unicorn과 Apache setup을 가지고있다. 내 Apache 설정은 아래에 있으며 production.rb는 this과 같습니다. h264 스트리밍을 사용하는 것이 좋지만 레일스가이 비디오 파일을 제공하고 있기 때문에 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 Iberess)가 서비스를 제공하지 않는 한 공개 디렉토리에서 파일을 사용할 수 없으므로 아무런 차이가 없습니다.

config.action_controller.asset_host를 사용해야합니까, 아니면 Apache 설정에 문제가 있습니까? 그냥 production.rb 코드에서

답변

19

나는이 문제 (예. 나에게도 일어난 일)에 대해 post을 가지고 있습니다. 도움이되기를 바랍니다. 그것은 당신의 Rewrite Rule

가 여기 내 아파치 서버 설정입니다 무시하기 때문

핵심은, 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 + 아파치 + 유니콘/얇은 찾은 모든 가이드가이 문제가 있습니다. – Rob

0

:

# 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을'헤더와 행의 주석을 해제하여 유니콘의 풀을 재시작하고 다시 시도합니다.

+0

감사하지만 이는 도움이되지 않았습니다. – jiriki