Hosting on IIS 6.0 revisited

Posted by matt.overstreet, Thu Mar 24 13:56:00 UTC 2011

IIS 6 logoRecently I've been setting up a rails install for Windows Server 2003/IIS 6. Googling reveals a few useful but out of date articles which mainly suggest running MS FastCGI for IIS 6. In the end I'm much more comfortable with a proxypass solution to thin or mongrel. This isn't supported out of the box by IIS 6, but finally there is a viable option with Ionics ISAPI Rewrite Filter.

I'm actively soliciting feedback or questions on this setup. Add comments here, in the cvreg google group, or directly to me @omnifroodle.

Assumptions

  • Windows Server 2003 (XP or 2k will not work)
  • IIS 6 (IIS 7 has it's own rewrite filter, so the IIRF instructions would change)
  • Should not interfere with other sites running on the IIS server

Installation and configuration

Ruby and bundler

Install Ruby 1.8.7-p334 from [[http://rubyinstaller.org/downloads]]

In a command window gem install bundler

Ruby Windows DevKit

You will need this in order to build native extensions, such as curb and nokogiri

Install the Ruby Windows DevKit from [[http://rubyinstaller.org/downloads]]

Follow the instructions from the DevKit wiki

  1. Extract the DevKit contents into a directory with no spaces, e.g. – C:\DevKit.
  2. Run ruby.exe dk.rb init
  3. Run ruby.exe dk.rb install

Rake

gem install rake

MSSql gem

In a command window gem install ruby-odbc gem install activerecord-sqlserver-adapter

You will need to setup a ODBC DSN in order to connect to the database. c:\Windows\system32\odbcad32.exe Create a system DSN with the "SQL Native Client adapter".

name: mondial_development select your database server

On the next page, select "With SQL Sever Authentication" and provide valid credentials.

On the next page, set the default database.

On the next page, disable "Perform translation for character data"

git

Install msysgit

Settings are not clear at this time, default to the less invasive options.

This will install a Git folder in your start menu with 2 applications (Git Bash and Git GUI)

reference: Github on installing on Windows

ssh key for github

See help document on Github.com

Pulling down the code

Run Git Bash


    cd /c/
    mkdir rails
    cd rails
    git clone git@github.com:username/appname.git

Install IIRF (Ionic's ISAPI Rewriting Filter) for x64

IIRF allows us to use many of the features of Apache's mod_rewrite for IIS 6. We use it to proxy requests for our rails app to our rails server process (mongrel or thin)

Download the IonicIsapiRewriter-2.1.1.25-Release-x64-bin.zip Note: if you are installing on 32bit windows you can just use the MSI Detailed install instructions for IIS 6 are under the heading "Installing IIRF" here

Roughly (more information at the url above or in the .chm included with IIRF)

  • place the IIRF.dll somewhere in the filesystem. If you have spaces in your path you'll need to make sure you quote the entire path in IIS settings later. (ex. C:\WINDOWS\system32\inetsrv\IIRF\IIRF.dll)

  • you may want to copy the rest of the bin directory to the folder you used above (optional)

  • add an empty IirfGlobal.ini to this same folder. It is used for global IIRF settings and we are putting it here as a placeholder.

  • Make sure your IIS user can see, traverse and read the folder you created. Adding the rights to the IISWPG group _should do the trick, depending on how heavily server modifications.

  • View the properties of your website in IIS Manager.

  • In the "ISAPI filters" tab add: Filter name: IIRF - Ionic ISAPI Rewriting Filter Executable: C:\WINDOWS\system32\inetsrv\IIRF\IIRF.dll

  • Enable the dll as an ISAPI extension so that the proxypass works for POST actions. In properties click Configuration on the "Home Directory" tab

  • Click Add. Executable: C:\WINDOWS\system32\inetsrv\IIRF\IIRF.dll Extension: .iirf Verbs: all Script Engine: on Verify that file exists: off

  • Add an IIRF.ini file to your apps root directory (public/ on a rails app)


    #  IIRF.ini
    #
    #  ini file for proxying to an internal webserver
    #

    RewriteLog c:\logs\iirf
    RewriteLogLevel 3
    IterationLimit 10
    MaxMatchCount 10
    RewriteEngine ON
    StatusInquiry ON

    #  act as a proxy the rails webserver
    RewriteCond         %{REQUEST_FILENAME}     !-f
    ProxyPass           ^/(.*)$   http://127.0.0.1:3000/$1
    ProxyPassReverse    /         http://127.0.0.1:3000/

Setup Mongrel_service

gem install mongrel_service
mongrel_rails service::install -N mondial_mobile_www /
          -c c:\rails\MyApp\ -p 3000 -e production

Notes

Thin instead of Mongrel

gem install thin

and then either the win32-service gem or with the native MS tool Srvany.exe.

Development MSSql server

If you are building a development installation you will also want to download Microsoft SQL Server 2005 Express Edition.

You will also need the .NET 2.0 framework 32-bit or .NET 2.0 framework 64-bit.

Filed Under: Blogroll Projects | Tags: 2003 iis rack rails server stone-age windows

Comments