Skip to content
Howard van Rooijen By Howard van Rooijen Co-Founder
A Step by Step Guide to Hosting TeamCity in IIS 7

Because we believe in working smarter, not harder, our Continuous Integration Server of choice is JetBrain's TeamCity.

We've believe that the combination of a virtualised development environment and a mature Continuous Integration Platform is a powerful one, especially because TeamCity allows us to easily scale out our build capacity by adding more Build Agents that can be hosted on Azure Virtual Machines or even Amazon EC2 instances.

In this Step by Step Guide we will show you how to configure TeamCity to run on Windows Server 2008 R2 and proxy requests through IIS 7 so that you can access your TeamCity server via a custom domain, for example http://teamcity.yourcompany.com

Programming C# 12 Book, by Ian Griffiths, published by O'Reilly Media, is now available to buy.

First download the TeamCity Windows Installer (WAR / JAR version are also available) – this is a totally self contained package that contains a pre-configured Apache TomCat instance.

The install experience is very straightforward, first run the installer:

Then accept the License Agreement:

01-02-team-city-install-license-agreement

We have modified the destination folder from the default (a Team City folder in the root of C) to install into Program Files (we are running on a 64bit server, hence the (x86)):

01-03-team-city-choose-install-location

Next select all the components you want installed on your server. The default topology allows you to configure both the CI Server and the Build Agents onto the same box – if you have a large team, who make a large number of commits – it might be advisable to scale out the Build Agents onto separate boxes.

01-04-team-city-choose-components

We have modified the configuration directory to sit inside the installation directory rather than in the user's profile folders. Click next to start the installation process.

01-05-team-city-specify-server-configuration-directory

The install process is quite quick…

01-06-team-city-installing

Once the installation has finished you will be presented with the following screen, which asks you to specify the port number that TeamCity will run on. This port number is used to configure TomCat which the Java based TeamCity server will be hosted in.

By default port 80 is entered – but this port is already being used by IIS 7, so change to port number to 8080 (assuming that you do not have another service listening on that port):

01-07-team-city-configure-server-port

Next you will be presented with the "Configure Build Agent Properties" screen. Note that it has been configured to look at the port number listed in the previous screen:

01-08-team-city-configure-build-agent-properties

Click "save" and you will see a confirmation dialog. Make a note of the location of the config file as you may need to edit it at some point in the future.

01-09-team-city-configure-build-agent-properties-saved

Next you will be presented with a screen that asks which Windows Account you wish to run the service under. System is the default selection.

01-10-team-city-select-service-account

Next you will be asked which services you wish to start immediately:

01-11-team-city-select-services-to-run

TeamCity is now successfully installed. When you click "Finish" you will be taken to the new TeamCity instance.

01-12-team-city-complete

TeamCity will now initialise and ask you to create an administrator account and configure a database. once you have done this you should be prompted to log-in. Note that TeamCity is only available to be resolved via localhost:8080.

In the following screen I have modified the default settings to prevent public registration – thus the only option when visiting the root of the TeamCity web app is to authenticate:

01-13-team-city-internal-web-address

Now that TeamCity is successfully installed and configured we need to configure IIS to proxy web requests from port 80 to TomCat which is listening on port 8080. The easiest way to configure IIS is via the wonderful Web Platform Installer. If you don't already have this installed on your server – you can download it from here.

The best hour you can spend to refine your own data strategy and leverage the latest capabilities on Azure to accelerate your road map.

Once installed, run the application and navigate to the Media Platform tab. Then click "Customize" on the "Host, deliver and Scale Using IIS Media Services" section:

02-01-web-platform-installer-media-platform

Select the "Application Request Routing 2.1" option and click "Install":

02-02-web-platform-installer-media-platform-application-request-routing

The next screen will show all the required dependencies for this feature. Click "I Accept" to download and install them:

02-03-web-platform-installer-media-platform-application-request-routing-license

The Web Platform Installer will now install the components, firstly the "Web Farm Framework 1.0":

02-04-web-platform-installer-media-platform-downloading-web-farm-framework

Next the "External Cache 1.0":

02-05-web-platform-installer-media-platform-downloading-external-cache

Next "URL Rewrite 2.0":

02-06-web-platform-installer-media-platform-downloading-url-rewrite-2-0

Next "Application Request Routing":

02-07-web-platform-installer-media-platform-downloading-application-request-routing-2-1

When this completes you will be shown a confirmation screen listing all the components that were installed:

02-08-web-platform-installer-media-platform-finished

Next open IIS 7 Manager. You should see a new node called "Server Farms":

03-01-iis7-server-farms

Right click on this node and select "Create Server Farm" from the context menu:

03-02-iis7-server-farms-context-menu

Next, enter a new Server Farm Name – call it "TeamCity", then click Next:

03-03-iis7-server-farms-specifcy-server-farm-name

Next, you will be prompted to add a server to the server farm:

03-04-iis7-server-farms-add-server

Click the "Advanced Settings" link:

03-07-iis7-server-farms-add-server

Now enter the IP address of the server to allow IIS to resolve to localhost:

03-05-iis7-server-farms-add-server-add-ip-address

Now update the httpPort to the number entered during the installation process – in our case this is 8080, click "Finish" once done:

03-06-iis7-server-farms-add-server-update-http-port-number

IIS will ask if you want it to create a URL rewrite rule. Click "Yes":

03-08-iis7-server-farms-rewrite-rules

Navigate up to the "Server Farms" node in the "Connections" pane – you should see that TeamCity is now listed as a Server Farm:

03-09-iis7-server-farms

Navigate up to your server node, and double click the "URL Rewrite" icon under the "IIS" section

04-01-iis-url-rewrite

This will display the rule that IIS automatically created for you in a previous step, double click this rule to edit it:

04-02-iis-rewriting

Expand the collapsed "Conditions" section:

04-03-iis-rewrite-rule

Click the "Add" button to add a new condition to the rule:

04-04-iis-rewrite-rule-conditions

By default the condition input field of this dialog contains {QUERY_STRING}, change this to {HTTP_HOST}:

04-05-iis-rewritie-rule-conditions-add-condition-input

Then in the "Pattern" field add your TeamCity subdomain – in our case this is ci.endjin.com:

04-06-iis-rewrite-rule-conditions-add-condition-add-pattern

Click OK and you will now see the new condition:

04-06-iis-rewrite-rule-conditions-add-condition-apply-changes

Note: Remember to click "Apply" in the right hand pane, in order to save these changes.

Now you should be able to resolve your TeamCity installation using it's public sub-domain address:

05-01-ci-endjin-com

Work Smarter, Not Harder.

@HowardvRooijen | @endjin

Howard van Rooijen

Co-Founder

Howard van Rooijen

Howard spent 10 years as a technology consultant helping some of the UK's best known organisations work smarter, before founding endjin in 2010. He's a Microsoft ScaleUp Mentor, and a Microsoft MVP for Azure and Developer Technologies, and helps small teams achieve big things using data, AI and Microsoft Azure.