我有 Rails 3.1、Unicorn 和 Apache 设置。我的 Apache 设置如下, Production.rb 看起来像this http://www.pastie.org/2859132。我喜欢使用 h264 流媒体,但由于 Rails 正在提供这些视频文件,因此 Apache Mod 将无法工作。
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 配置有问题。
我有一个post http://tech.manic.tw/2012/02/22/Apache-with-Unicorn.html对于这个问题(是的,这也发生在我身上),希望它会有所帮助。
关键是去掉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>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)