IIS with Rails

Subscribe to IIS with Rails 13 posts, 8 voices

 
Avatar jc 3 posts

Anyone get this to work? http://made-of-stone.blogspot.com/2006/01/rails-on-iis-revisited.html

I tried it on XP and failed miserably. If someone has got it to work, maybe I’ll try to troubleshoot some more.

 
Avatar Chris Jennings 17 posts

I suggest trying these resources. They seem to be much more up-to-date: http://www.napcs.com/howto/rails/deploy/

 
Avatar Jeff Cohen 89 posts

This is the biggest problem with Rails right now for us Microsoft developers: being able to deploy on a Windows server. It’s not Rails’ fault, it’s Microsoft’s.

Web server architecture is not my specialty, but as I understand it, you want your web server software (IIS, Apache) to accept incoming connections on port 80, and then route the http request to a “handler” of some kind; IIS does this by file extension primarily, so you have .asp being handled by one process, .aspx handled by another, etc.

So the problem is mainly one of getting IIS to hand off the request to the ruby interpreter and receive the response. Oh, and it has to do this efficiently.

In the Linux/Apache, it’s normal to have your webserver (say Apache) just forward the incoming request to another program first, which in turn will send it to the handler. Nowadays, Mongrel is the web server for Rails, and Apache is told to just forward the port 80 traffic to a particular Mongrel instance; in this way Apache front-ends all your web traffic, Mongrel worries about loading the Ruby interpreter efficiently, and your Rails app is none the wiser.

Back in the IIS world, getting an “in-between” program to handle the requests is ridiculously hard. You have to find some way of proxying the requests between IIS and Mongrel, and wow, it’s nearly impossible. Brian Hogan’s site (napcs.com) that Chris mentioned is in fact the best resource to date.

Microsoft is also working on a “FastCGI” handler to support PHP, and they’re also trying to get it to work with Rails; this is for IIS7 only, and it’s unclear if IIS -> FastCGI -> Ruby will be any better than Apache -> FastCGI -> Ruby, which sucked.

Why IIS can’t do the normal things that Apache can do, I have no idea… and perhaps explains why most of the world runs Unix or Linux servers even if they run Windows desktops.

People who know more than me in this area, please chime in and/or correct anything I’ve said.

 
Avatar Chris Jennings 17 posts

Jeff, nice summary. You pretty much hit the nail on the head. Deployment in Windows shops is a showstopper for many folks. I’m holding out some hope for the FastCGI stuff in IIS7, but we’ll have to wait and see. The closest I’ve come to deploying Rails on Windows is running Mongrel as a Win32 service, but that’s only feasible for small intranet apps….which may be fine for many people to begin introducing Rails in their day jobs.

 
Avatar Mike Gunderloy 35 posts

I can think of a couple of things I’d do before trying to serve a Rails app via IIS:

1. Install Apache on Windows and go from there. The Apache install on Windows isn’t all that tough, and it works well once it’s there. Just forget about IIS. Presumably (haven’t tried) you could then go on to get Apache to hand off to Mongrel on Windows.

2. Put a VM on the Windows box, put Ubuntu server (or whatever your Linux distro of choice) on the VM, and serve from there on the standard Linux/Apache stack. Of course then you need to know enough about networking to handle port forwarding into the VM, or get a second IP for the physical box that can be handed to the VM.

But unless I was really hamstrung with corporate policies and utterly unable to deploy an alternative, I don’t think I’d be trying to do this from IIS directly.

 
Avatar AJ Finch 2 posts

This may be wandering off this particular topic, but if you want to explore running Rails on Windows, then Instant Rails has worked very well for me. It’s a 1-minute install. I haven’t had any problems (but then, I haven’t pushed it too hard).

 
Avatar jc 3 posts

Finch: Instant Rails works great for me too. I just like the idea of running rails within IIS because it could open up all sorts of possibilities to plug new functionality (using rails) into an existing ASP.NET applications

 
Avatar Sam 26 posts

I like Mike’s second suggestion….it seems the best to me. I hope to sneak Rails into my workplace that way. :)

 
Avatar Brian Hogan 10 posts

Well, I wrote the articles listed above http://www.napcs.com/howto/rails/deploy/) and I work with Rails on Windows quite frequently. The solutions I outlined work great, but what works even better is using a VM as Mike Gunderloy suggested. The upcoming Rails deployment book will have more information on this subject.

Windows deployment is actually very easy… it’s just slow, and that’s because Ruby run slow on Windows. Until that gets fixed, you’ll just need more resources.

Running Rails in IIS is just not a good idea. You can make the applications appear to run through IIS which lets you embed the apps anywhere in your site structure and even use your certificates, but you should handle integration between apps by making them talk using REST or another method rather than adopting any proprietary integration techniques that rely on IIS.

 
Avatar Craig Beck 1 post

Anyone dealt with Active Directory authentication and Rails?

 
Avatar Mike Gunderloy 35 posts

Fresh info from the IIS team on how to make the latest tech preview of their FastCGI implementation play with Rails: 10 steps to get Ruby on Rails running on Windows with IIS FastCGI

 
Avatar Chris Jennings 17 posts

Wow. I’ll be trying this right away. Thanks for the link, Mike.

 
Avatar Brian Hogan 10 posts

Heheheh glad the cat’s out of the bag on that. Been wanting to mention that.