1

我正在尝试让 Ruby on Rails 运行在 Windows 2003 Server 上。我已经安装了 Mongrel 服务和 Apache(以及 RoR 等)。

当我只使用 Mongrel 为应用程序提供服务时,一切都完美无缺。

所以,现在我要了解 Apache 配置了……显然我似乎无法做到这一点。当我访问我的页面时,我返回了正确的 HTML,但返回的内容类型设置为 text/plain 而不是 html 或 xhtml...此外,如果我尝试访问其中一个 css 页面,我获得 500 内部服务器错误(以 HTML 形式返回,与 text/plain Content-Type 一起返回)。

这是我的虚拟主机文件(非常感谢任何帮助!):

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>
4

2 回答 2

1

好的,这是答案的一部分。这部分处理 .css 和 .js 文件。显然它与尾部斜杠有关......我不得不删除一些斜杠并添加一些其他的......

删除:

  DocumentRoot c:/www/app/public

  <Directory c:/www/app/public >

添加:

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

现在我可以很好地提取 .css 和 .js 文件了......

但是:我仍然遇到 Apache 未发送正确标头的问题。在我返回的 HTML 中,我有这个:

但它仍然返回 text/plain(在 httpd.conf 中设置的 DefaultType)。

拜托,如果有人有任何想法,请告诉我!!!!!!!

谢谢

于 2010-08-14T13:54:18.480 回答
0

我强烈推荐一个用于 RoR 的 linux 主机。Unicorn 和Passenger 是比杂种集群更好的工具。请参阅github 博客文章。

于 2010-08-14T14:14:54.460 回答