Creating a HTTP handler for IIS that transparently forwards request to different port?

Posted by Lasse V. Karlsen on Stack Overflow See other posts from Stack Overflow or by Lasse V. Karlsen
Published on 2010-04-28T20:55:34Z Indexed on 2010/04/28 20:57 UTC
Read the original article Hit count: 230

Filed under:
|
|

I have a public web server with the following software installed:

  • IIS7 on port 80
  • Subversion over apache on port 81
  • TeamCity over apache on port 82

Unfortunately, both Subversion and TeamCity comes with their own web server installations, and they work flawlessly, so I don't really want to try to move them all to run under IIS, if that is even possible.

However, I was looking at IIS and I noticed the HTTP redirect part, and I was wondering...

Would it be possible for me to create a HTTP handler, and install it on a sub-domain under IIS7, so that all requests to, say, http://svn.vkarlsen.no/anything/here is passed to my HTTP handler, which then subsequently creates a request to http://localhost:81/anything/here, retrieves the data, and passes it on to the original requestee?

In other words, I would like IIS to handle transparent forwards to port 81 and 82, without using the redirection features. For instance, Subversion doesn't like HTTP redirect and just says that the repository has been moved, and I need to relocate my working copy. That's not what I want.

If anyone thinks this can be done, does anyone have any links to topics I need to read up on? I think I can manage the actual request parts, even with authentication, but I have no idea how to create a HTTP handler.

Also bear in mind that I need to handle sub-paths and documents beneath the top-level domain, so http://svn.vkarlsen.no/whatever/here needs to be handled by a single handler, I cannot create copies of the handler for all sub-directories since paths are created from time to time.

© Stack Overflow or respective owner

Related posts about iis7

Related posts about httphandler