2010-08-14 78 views
1

我試圖讓Ruby on Rails在Windows 2003 Server上運行。我已經安裝了Mongrel服務和Apache(以及RoR等)。Apache + Mongrel Cluster =錯誤的服務器配置!

當我使用Mongrel服務一個應用程序時,一切都完美了。

所以,現在我下來的Apache配置...顯然我似乎無法得到正確的。當我訪問我的頁面時,我返回了正確的HTML,但它返回的Content-Type設置爲text/plain,而不是html或xhtml ...另外,如果我嘗試訪問某個CSS頁面,得到500內部服務器錯誤(作爲HTML返回,返回文本/普通內容類型)。

這是我的虛擬主機文件(任何幫助將是非常非常非常感謝!):

NameVirtualHost *:8080 


#Proxy balancer section (create one for each ruby app cluster) 
<Proxy balancer://myapp_cluster> 
    Order allow,deny 
    Allow from all 
    BalancerMember http://rails.localdomain.com:3010 
    #BalancerMember http://myapp:3011 
</Proxy> 




#Virtual host section (create one for each ruby app you need to publish) 
<VirtualHost *:8080> 
    ServerName rails.localdomain.com 
    DocumentRoot c:/www/app/public/ 

    <Directory c:/www/app/public/ > 
     Options Indexes FollowSymLinks MultiViews 
     AllowOverride All 
     Order allow,deny 
     allow from all 
    </Directory> 

    ProxyRequests Off 
    ProxyPass/balancer://myapp_cluster 
    ProxyPassReverse/balancer://myapp_cluster 
    ProxyPreserveHost On 
    #SetOutputFilter INFLATE;DEFLATE 
    #SetOutputFilter proxy-html 

    #log files 
    ErrorLog c:/www/log/app_error.log 
    # Possible values include: debug, info, notice, warn, error, crit, 
    # alert, emerg. 
    LogLevel warn 
    CustomLog c:/www/log/app_access.log combined 

    #Rewrite stuff 
    RewriteEngine On 

    # Check for maintenance file and redirect all requests 
    RewriteCond %{DOCUMENT_ROOT}/system/maintenance.html -f 
    RewriteCond %{SCRIPT_FILENAME} !maintenance.html 
    RewriteRule ^.*$ /system/maintenance.html [L] 

    # Rewrite index to check for static 
    RewriteRule ^/$ /index.html [QSA] 

    # Rewrite to check for Rails cached page 
    RewriteRule ^([^.]+)$ $1.html [QSA] 

    # Redirect all non-static requests to cluster 
    RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f 
    RewriteRule ^/(.*)$ balancer://myapp_cluster%{REQUEST_URI} [P,QSA,L] 


    # Deflate 
    #AddOutputFilterByType DEFLATE text/html text/plain text/xml application/xml application/xhtml+xml text/javascript text/css 
    #BrowserMatch ^Mozilla/4 gzip-only-text/html 
    #BrowserMatch ^Mozilla/4\.0[678] no-gzip 
    #BrowserMatch \\bMSIE !no-gzip !gzip-only-text/html 

</VirtualHost> 
+1

噢,我可以在httpd.conf文件中將「DefaultType text/plain」更改爲「DefaultType text/html」,並讓我的HTML頁面顯示正確,但其他所有內容仍然是borked ... ..(加上我不認爲這是正確的路線)。 – 2010-08-14 06:34:34

+0

(當我說「其他」時,我的意思是諸如我的CSS和JS頁面等等) – 2010-08-14 06:36:50

回答

1

OK,這裏的答案部分。這部分涉及.css和.js文件。顯然,這涉及到結尾的斜槓......我不得不刪除一些斜線和添加一些人...

刪除:

DocumentRoot c:/www/app/public 

    <Directory c:/www/app/public > 

補充:

ProxyPass/balancer://myapp_cluster/ 
    ProxyPassReverse/balancer://myapp_cluster/ 

現在我可以拉起的.css和.js文件就好了...

但是,我仍然有問題的Ap疼不發送正確的標題。沒錯,這是我返回HTML裏面我有這樣的:

但它仍然返回text/plain的(在缺省的類型爲在httpd.conf中設置)。

請問,如果有人有任何想法,讓我知道!!!!!

謝謝

+0

我認爲,沒有設置內容類型標頭的是mongrel_cluster。 – Vanuan 2010-11-30 22:23:21

+0

檢查http://rails.localdomain.com:3010是否返回正確的內容類型。如果它什麼都沒有返回,那麼apache會應用默認的。 – Vanuan 2010-12-01 00:08:34