improve.dk
Just another mindless drone looking for the perfect stack
posts - 227, comments - 489

Routing requests for a subdirectory to another server using IIS Application Request Routing

Written on June 21, 2010 by Mark S. Rasmussen in Sysadmin: IIS

In this post I'll walk you through how to setup IIS Application Request Routing so that any requests for a /wiki/ subdirectory are routed onto a separate server, while all other requests are handled by the server itself.

Let's imagine a fictional scenario where I want to add a wiki to my website. Thus, all requests to improve.dk/wiki/* are mapped to a dedicated LAMP based server that runs some kind of wiki software. All other requests should be served by the normal improve.dk webserver.

The first task is to setup a new server farm, called Wiki in my case. Add the server to the list of servers, using its hostname, MyWikiServer in this case. If you setup (temporarily, for testing) improve.dk so it maps to the wiki server, requesting http://improve.dk/Wiki/ should return back the expected result from the wiki server, if requested from the normal webserver.

rrsa1


    
        
    
    
        
            
            
        
    

Next, setup a URL Rewrite rule at the global level like the following:

rrsa2


    
        
            
            
                
            
            
        
    

The rule matches all requests for the /wiki/ directory, whether there's a trailing slash or further subdirectories. It ensures not to match a request like /wikipedia/. The request is routed onto the Wiki webfarm which sends the request onto the MyWikiServer server. Note that there's a condition ensuring this rule will only match requests for the improve.dk domain so other websites aren't affected. There are no changes to the actual improve.dk website setup.

Feedback

Gravatar

Luke Puplett wrote on 6/22/2010 11:32 AM

This definitely sounds like the sort of thing I'll be scouring the internet for in the future: bookmarked. A great blog - always useful info.
Gravatar

Suhaib wrote on 6/6/2011 1:46 PM

Dear Mark

Firstly thank you so much for the helpul blogpost. I even read your replies in the dicussion at iis forums and got the link to this page.

I wish to accomplish something very similar except:

1. I want to route requests for a particular sub-domain to Apache rather than a sub-directory.
2. I want to install Apache on the same box (Wind 2003) as IIS.

So, how do I create a server farm for Apache which is present on the same machine?

And how do I construct my rewrite rule to forward all requests for a particualr sub-domain to Apache?
Gravatar

Mark S. Rasmussen wrote on 6/9/2011 2:00 PM

@Suhaib

Filtering on the hostname is similar to what I'm doing. Just make sure your <match> element matches all urls. Then add appropriate <condition>'s for matching the hostnames by pattern. If you add two rules - one for each hostname, then you can rewrite each one to each server.

If you want Apache on the same machine, you need to make sure it's not running on port 80. Then you can rewrite the requests for the Apache server, hitting ARR on port 80, to the internal Apache port.

Post Comment

Name  
Email
Url
Comment
Please add 7 and 6 and type the answer here: