问题描述
我的Rails 3.1,独角兽和Apache设置。我的Apache设置下方production.rb看起来像。我喜欢用H264流,但由于Rails正在提供这些视频文件,Apache的国防部将无法工作。
I have Rails 3.1, Unicorn and Apache setup. My Apache settings are below and production.rb looks like this. I like using h264 streaming but since Rails is serving these video files, the Apache Mod won't work.
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或我不能下载任何东西静电。我有precompiled资产太多,但它不会作出任何文件的任何区别可从公共目录中,除非滑轨(机架式我猜)是做投放。
I have to enable serve_static_assets or I cannot download any static stuff. I have precompiled assets too but it won't make any difference as no file is available from public directory unless Rails (Rack I guess) is doing the serving.
我应该使用config.action_controller.asset_host还是有我的Apache配置有些不妥。
Should I use config.action_controller.asset_host or is there something wrong with my Apache config.
推荐答案
我有一个的对于这个问题(是的它也发生在我身上),希望这将有助于。
I have a post for this problem (yeah it also happened to me), hope it will help.
关键是去除的ProxyPass /平衡器:// unicornservers /
模式,因为它会覆盖您的重写规则
The key point is to remove ProxyPass / balancer://unicornservers/
pattern, because it would override your Rewrite Rule
下面是我的Apache服务器配置。
Here is my apache server config.
<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>
这篇关于Rails的3.1,独角兽和Apache:静态文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!