Up until recently I have been using the apache isapi redirector to proxy through from IIS to TeamCity (which runs on Tomcat). This was because I had no alternative until today. Whilst searching the interwebs I came across the Application Request Routing extension for IIS7. This amongst other things allows IIS to proxy through to a service running either locally or remotely running on any port.
Installation
Install the extension using the Web Platform Installer, this will install a number of prerequisites as well as the Application Request Routing extension.
Configuration
- Once the installation is complete open up the IIS7 management tool where you should now see a new node under the websites folder for your server called server farms.
- Right click and add a new Farm and name it TeamCity.
- Click on the advanced settings and enter the correct port number for TeamCity, you will not be able to change this so get it right or you will have to delete the server entry and start again.
- One you have added the server accept the request to automatically create the rules.
That’s it, any request to your server should now proxy through to TeamCity.
Hosting more than one site
You may want to or you may already be hosting sites on your server via IIS. With what we have done above these sites will no longer be available. To resolve this click on the server node in the IIS management tool. Click on the url rewriting component, this will show you the rule that was created for your Server Farm. Double click the rule and a new condition:
- Condition input: {HTTP_HOST}
- Pattern: <Host/Domain name>, example teamcity.mydomain.com
- Apply the rule.
This should now only push requests to the specified domain name to the proxy. Other sites can now be hosted as normal.