views:

20

answers:

2

Hi! I'm trying to get Ruby on Rails going on a Windows 2003 Server. I've installed the Mongrel service and Apache (and RoR, etc).

When I serve an app using just Mongrel, everything comes up perfectly.

So, now I am down to the Apache configuration... Apparently I can't seem to get that right. 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).

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>
A: 

OK, here's part of the answer. This part deals with the .css and .js files. 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...

HOWEVER: I am still having the issue of Apache NOT sending the right headers. Right inside the HTML that I'm returning I have this:

But it's STILL returning text/plain (the DefaultType as set in the httpd.conf).

PLEASE, if anyone has any ideas, let me know!!!!!

Thanks

Mr M
A: 

I heavily recommend a linux host for RoR. Unicorn and Passenger are way better tools than mongrel clusters. See github blog post about it.

Tass