简体   繁体   English

Apache + Mongrel群集=错误的服务器配置!

[英]Apache + Mongrel Cluster = Wrong server config!

I'm trying to get Ruby on Rails going on a Windows 2003 Server. 我正在尝试使Ruby on Rails在Windows 2003 Server上运行。 I've installed the Mongrel service and Apache (and RoR, etc). 我已经安装了Mongrel服务和Apache(以及RoR等)。

When I serve an app using just Mongrel, everything comes up perfectly. 当我仅使用Mongrel来提供应用程序时,一切都会顺利进行。

So, now I am down to the Apache configuration... Apparently I can't seem to get that right. 因此,现在我只能使用Apache配置了……显然我似乎做不到。 When I visit my pages, I am returned the correct HTML, but it's returned with the Content-Type set to text/plain instead of html or xhtml... In addition, If I try to get to one of the css pages, I get a 500 Internal Server error (served back as HTML, returned with the text/plain Content-Type). 当我访问我的页面时,我返回了正确的HTML,但是返回的是Content-Type设置为text / plain而不是html或xhtml...。此外,如果我尝试进入其中一个CSS页面,收到500内部服务器错误(以HTML形式提供,以文本/纯内容类型返回)。

Here is my Virtual Host file (Any help would be VERY VERY VERY appreciated!): 这是我的虚拟主机文件(任何帮助将非常非常感谢!):

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>

OK, here's part of the answer. 好,这是答案的一部分 This part deals with the .css and .js files. 此部分处理.css和.js文件。 Apparently it relates to trailing slashes... I had to remove some slashes and add some others... 显然,这与尾随的斜杠有关。我必须删除一些斜杠并添加其他一些斜杠。

Removed: 已移除:

  DocumentRoot c:/www/app/public

  <Directory c:/www/app/public >

Added: 添加:

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

Now I can pull up the .css and .js files just fine... 现在,我可以拉出.css和.js文件了……

HOWEVER: I am still having the issue of Apache NOT sending the right headers. 但是,我仍然遇到Apache无法发送正确标题的问题。 Right inside the HTML that I'm returning I have this: 就在我要返回的HTML里面,我有这个:

But it's STILL returning text/plain (the DefaultType as set in the httpd.conf). 但是它仍然会返回文本/纯文本(httpd.conf中设置的DefaultType)。

PLEASE, if anyone has any ideas, let me know!!!!! 如果有人有什么想法,请告诉我!

Thanks 谢谢

I heavily recommend a linux host for RoR. 我强烈推荐RoR使用Linux主机。 Unicorn and Passenger are way better tools than mongrel clusters. 与杂种集群相比,独角兽和乘客是更好的工具。 See github blog post about it. 请参阅github博客文章。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM