TeamCity behind nginx proxy

I am trying to configure TeamCity for nginx. I would like to https://public.address.com/teamcity/ ... redirect to http://127.0.0.1:8111/ ... but although nginx does this successfully, the login page returns with links that look like the following way:

<script type="text/javascript" src="/res/-8762791360234593415.js?v=1305815890782"></script> 

Obviously, this will not happen, and the use of the rootURL parameter ( server URL: in Server Configuration ) does not matter.

How to run TeamCity behind a proxy server at a non-root URL?


FWIW, here is the relevant part of my nginx configuration:

 location /teamcity/ { proxy_pass http://127.0.0.1:8111/; proxy_redirect http://127.0.0.1:8111/ https://$host/teamcity/; } 
+7
source share
2 answers

(I ended up tracking the solution myself ...)

Install tomcat, then install the WAR version of TeamCity, which is located in the download area above the Java EE Container tab. This provides TeamCity under the base URL that you can select at the time of installing WAR.

The easiest way is to copy the .war file to the Tomcat webapps directory, giving it a name that matches the desired base URL. For example, setting teamcity.war to $TOMCAT_HOME/webapps will load TeamCity under the URL http://localhost:8080/teamcity (assuming Tomcat is installed by default). Proxying from https://public.address.com/teamcity to this internal address must be fair in nginx.

I could not start it right after installing the .war file, but after rebooting Tomcat everything worked out.

+3
source

I did this using the standard Teamcity Windows installer and supposedly worked on any platform.

Change Teamcity Location

According to a comment by a JetBrains employee :

To change the TeamCity address from http://server/ to http://server/teamcity/ , rename the <TeamCity home>\webapps\ROOT to <TeamCity home>\webapps\teamcity .

Please note that you will need to rename this directory each time you upgrade Teamcity.

Proxy configuration

The nginx configuration looks something like this:

  location /teamcity/ { proxy_pass http://teamcity-server.domain.com/teamcity/; } 

Or you can use Apache (I switched to Apache due to the authentication requirements that I had):

  <Location /teamcity> ProxyPass http://teamcity-server.domain.com/teamcity ProxyPassReverse http://teamcity-server.domain.com/teamcity </Location> 

Redirect old URL

I also created a new <TeamCity home>\webapps\ROOT and put the index.jsp file in it, which redirects to the new URL, so the old links continue to work (for example, if someone goes to http: // teamcity-server .domain.com it redirects to http://teamcity-server.domain.com/teamcity ):

 <!DOCTYPE html> <html> <head> <title>TeamCity</title> <meta http-equiv="refresh" content="0;url=/teamcity/overview.html"/> </head> <body> <!-- no content --> </body> </html> 

You can also do a redirect to nginx / apache, but execution on Teamcity server means that if someone goes to the old URL directly on the teamcity web server (instead of your proxy server), they will still be redirected correctly (instead this 404).

+14
source

All Articles