我試圖讓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>
噢,我可以在httpd.conf文件中將「DefaultType text/plain」更改爲「DefaultType text/html」,並讓我的HTML頁面顯示正確,但其他所有內容仍然是borked ... ..(加上我不認爲這是正確的路線)。 – 2010-08-14 06:34:34
(當我說「其他」時,我的意思是諸如我的CSS和JS頁面等等) – 2010-08-14 06:36:50