Extended Caveat Guide for Deploying Ruby on Rails on Windows

024th Jan 2008My Notes, , ,

I was alerted on some issues on my deployment of our Ruby on Rails app on our Windows server.

We’re proxying our Mongrel cluster through Apache and apparently, our Apache seem to be behaving funny. When accessing http://www.domainexample.com/app1, without a trailing slash, I can see that Apache proxies to that app but the Ruby app can’t detect that it’s on app1 folder and all the paths go bonkers.

When a trailing slash is used like http://www.domainexample.com/app1/, the app works correctly. So after stabbing-in-the-Apache-dark for close to 4 more days, the solution, uniquely for me, was to remove one freaking line!

In Brian Hogan’s tutorial, you had to do the following in a file called httpd-proxy.conf:

ProxyPass /app1/ http://127.0.0.1:4000/
ProxyPass /app1 http://127.0.0.1:4000/
ProxyPassReverse /app1/ http://127.0.0.1:4000/

But the second line is unnecessary. However, when you remove it, it still has problems. You need to edit the 3rd line too. This is how apache will automatically add the trailing slash for you:

ProxyPass /app1/ http://127.0.0.1:4000/
ProxyPassReverse /app1 http://127.0.0.1:4000/

Notice that in ProxyPassReverse, app1 does not have a trailing slash. This somehow works for me and everytime I access the app without the trailing slash, everything works sweetly.

Some of you may also ask how do I get nice long names to display on the URI?

If you see my Prayer Locater app at http://www.reqa.com:8080/prayerlocater, the directory, prayerlocater is obviously more than 8 characters long.

Lets say, I had generated a new rails project on my very old Windows Server like this -> ruby rails anewproj

And then I launch the application on Mongrel using the port 8000.

In the httpd-proxy.conf file, do this, changes are made in red ->

##################### MONGREL #########################
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so

ProxyRequests Off

<Proxy *>
Order deny,allow
Allow from all
</Proxy>

#################################

Alias /prayerlocater “c:/web/anewproj/public”
<Directory “C:/web/anewproj/public”>
Options Indexes FollowSymLinks
AllowOverride none
Order allow,deny
Allow from all
</Directory>

ProxyPass /prayerlocater/images !
ProxyPass /prayerlocater/stylesheets !
ProxyPass /prayerlocater/javascripts !

ProxyPass /prayerlocater/ http://127.0.0.1:8000/
ProxyPassReverse /prayerlocater http://127.0.0.1:8000/

########################################

As you can see, ProxyPassReverse does not have a trailing slash on the Alias. What this does is that for every access to /prayerlocater, Apache will redirect to /prayerlocater/. This will make all non-trailing slash access complete with a trailing slash.

Hope you guys have a better understanding of how to deploy Ruby on Rails on Windows now.

This article is a partial. For complete understanding, please read the following article first ->

http://mag.typecanvas.com/2008/01/19/deploying-rails-to-an-old-windows-server/

No Comments Comments Feed

  1. TypeCanvas Mag » Blog Archive » Deploying Rails to an old Windows Server (January 24, 2008, 6:33 pm).

    [...] Note: This is incomplete caveats. Please visit this article for extended caveat guide -> http://mag.typecanvas.com/2008/01/24/extended-caveat-guide-for-deploying-ruby-on-rails-on-windows/ [...]

Add a Comment

You must be logged in to post a comment.