Apache as reverse proxy for TeamCity

Got a feeling this should be a simple one, but it's beating me so far. I'm trying to have Apache act as a reverse proxy for our TeamCity server.

Does anyone have a working configuration for Apache in this situation that they'd care to share?

I've got Apache 2.2.8 with mod_proxy_html 3.0 and I've moved my TeamCity installation from /ROOT to /teamcity to help the mod_proxy_html parsing.

My config looks something like this:


  1. Default mod_proxy_html conf file

Include conf/extra/proxy_html.conf

ProxyRequests Off

Order deny,allow Allow from all ]]>

ProxyPass /builds/ http://teamcity.mydomain.com:8080/teamcity/
ProxyPassReverse /builds/ http://teamcity.mydomain.com:8080/teamcity/

SetOutputFilter proxy-html

ProxyHTMLExtended on
ProxyHTMLURLMap /teamcity /builds

ProxyPassReverseCookiePath /teamcity/ /builds/
ProxyPassReverseCookieDomain teamcity.mydomain.com frontend.mydomain.com


I can see the TeamCity login page ok (style sheets are working too) but hitting the login button always brings me to http://frontend.mydomain.com/teamcity/overview.html It's also complaining about cookies not being enabled.

Any ideas, anyone? Any help gratefully received!



Comment actions Permalink

If you point your browser to some URL inside TeamCity and TeamCity detects that you are not authenticated the original URL is remembered and after the login you will be pointed to the remembered url. Probably this is what you are experiencing.

Pavel Sher

Comment actions Permalink

Add this to your Apache conf file

LoadModule proxy_module bin/mod_proxy.so
LoadModule proxy_http_module bin/mod_proxy_http.so

ProxyPass /TeamCity http://localhost/TeamCity
ProxyPassReverse /TeamCity http://localhost/TeamCity

Add the Context to your TeamCity conf server.xml file in the Host section

<Host name="localhost"  appBase="webapps"

            unpackWARs="true" autoDeploy="true"

            xmlValidation="false" xmlNamespaceAware="false">

<Context path="/TeamCity"



     reloadable="true" > </Context>

UPDATE by Yegor Yarko:
Please do not add contexts into server.xml. This might result in two TeamCity instances running.
Another approach.

Comment actions Permalink


Im confused with the following line

ProxyPass /TeamCity http://localhost/TeamCity
ProxyPassReverse /TeamCity http://localhost/TeamCity

should or could localhost be the name or ip address of the teamcity server.

I am planning to setup a apache server in a dmz and open ports to the internal teamcity server and am confused what localhost should be ?

Comment actions Permalink

Yes, it was just an example.
You need to specify actual address of TeamCity instance.

Comment actions Permalink

When i add this
<Context path="/TeamCity"
     reloadable="true" > </Context>

I get the following error

[2011-05-31 15:35:23,395]  ERROR -   jetbrains.buildServer.SERVER - Server startup exception: jetbrains.buildServer.serverSide.db.SecondTeamCityInstanceException: Attempt to start more than one TeamCity server connected to the same database.

jetbrains.buildServer.serverSide.db.SecondTeamCityInstanceException: Attempt to start more than one TeamCity server connected to the same database.

                at jetbrains.buildServer.serverSide.db.TeamCityDatabaseManager.lock(TeamCityDatabaseManager.java:342)

                at jetbrains.buildServer.rootDispatcher.TeamCityDispatcherServlet.processStartupServerInternal(TeamCityDispatcherServlet.java:130)

                at jetbrains.buildServer.rootDispatcher.TeamCityDispatcherServlet.processStartupServerSafe(TeamCityDispatcherServlet.java:128)

                at jetbrains.buildServer.rootDispatcher.TeamCityDispatcherServlet.access$400(TeamCityDispatcherServlet.java:306)

                at jetbrains.buildServer.rootDispatcher.TeamCityDispatcherServlet$6.run(TeamCityDispatcherServlet.java)

Comment actions Permalink

The issue has been resolved by email, but for reference.
To change TeamCity address from http://server/ to http://server/teamcity/, move <TeamCity home>\webapps\ROOT directory to <TeamCity home>\webapps\teamcity.

Comment actions Permalink

Reviving an old thread to give a set up that worked for me:


  • TeamCity is installed in  http://server:8111/
  • You want to access it via  http://server/tc/

     1. Move TeamCity installation in Tomcat
          cd  <TeamCity>/webapps
          mv  ROOT  tc

          Restart TeamCity
          /sbin/service  teamcity  restart

          Now TeamCity is accessible via  http://server:8111/tc/

     2. Set up reverse proxy on your httpd server
          vi  /etc/httpd/conf.d/<yourconfig>.conf

          Paste in the following:
          ProxyRequests  Off
     ProxyPass         /tc  http://server:8111/tc
     ProxyPassReverse  /tc  http://server:8111/tc

          Restart httpd
          /sbin/service  httpd  restart

          Now TeamCity is accessible via  http://server/tc/

     3. ...?

     4. Profit!

Comment actions Permalink

Thanks for sharing!


Please sign in to leave a comment.