2011-12-26 105 views
2

我使用rails 3.0.7,我在生產環境中安裝了apache2 + unicorn。服務靜態文件,apache +獨角獸

我有我的.conf文件如下

<VirtualHost *:80> 
ServerName something.com 

# Point this to your public folder of teambox 
DocumentRoot /pal/public 

RewriteEngine On 

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

# Redirect all non-static requests to unicorn 
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> 

試圖RewriteCond %{REQUEST_FILENAME} !-f

但似乎Apache不服務於靜態請求(在公共目錄中的文件)。所有的靜態請求也涉及到rails。我錯過了什麼配置?

+0

我會把[Nginx](http://nginx.org)而不是Apache。處理靜電要好得多。 – 2011-12-26 11:36:21

+0

Yup意識到這一點..但商界人士.. !!!不能幫助那部分 – 2011-12-26 11:45:45

+0

那麼把nginx放在apache前面呢? :-) – 2011-12-26 11:47:21

回答

1

我知道這個問題是相當過時,但... 我有完全相同的問題,並找不到解決方案的任何地方。 我碰到過this question

刪除以下工作。

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