Build hangs when using alias in buildAgent.properties serverUrl

 

I'm having an issue where my builds hang on the Starting the build on the agent <...> step if the serverUrl in the buildAgent.properties file is using a hostname (ie http:\://teamcity) rather than the actual server name.

My teamcity is running on a windows 2k16 server and I'm using IIS as a reverse proxy.

This used to work with no issues and broke while I was making seemingly unrelated changes to other sites on the same IIS server earlier today (I created new sites and installed microsoft web-deploy functionality).

If I change the serverUrl to use the actual servername the build starts working again. I'd prefer to use the alias to make future server migrations smooth and I'm not sure why it stopped working.

I can attach server logs if it helps, but in summary the teamcity-server.log shows the agent trying to register while it is already registered.  At the same time, the IIS logs show a 401 on a post to /RPC2 from the agent server and the agent log shows "Failed to perform remote command '1 log messages'... Unauthorized" and "Failed to perform remote command 'pingAndReRegister'..."

My reverse proxy setup is as follows:
<rules>
<rule name="TeamCityReverseProxyInboundRule" patternSyntax="Wildcard" stopProcessing="true">
<match url="*" />
<action type="Rewrite" url="http://localhost:8070/{R:1}" logRewrittenUrl="true" />
<conditions logicalGrouping="MatchAny">
<add input="{HTTP_HOST}" pattern="teamcity" />
<add input="{HTTP_HOST}" pattern="teamcity.mydomain.corp" />
</conditions>
<serverVariables>
<set name="HTTP_X_FORWARDED_HOST" value="{HTTP_HOST}" />
<set name="HTTP_X_FORWARDED_SERVER" value="{HTTP_HOST}" />
<set name="HTTP_X_FORWARDED_PROTO" value="http" />
<set name="HTTP_X_FORWARDED_PORT" value="80" />
<set name="SERVER_NAME" value="{HTTP_HOST}" />
</serverVariables>
</rule>
</rules>

Anonymous and Basic authentication are enabled on the reverse proxy site in IIS.

my teamcity server.xml has the RemoteIpValve uncommented

<Valve
className="org.apache.catalina.valves.RemoteIpValve"
remoteIpHeader="x-forwarded-for"
protocolHeader="x-forwarded-proto"
internalProxies="<proxy server ip>"
/>

Is the proxy failing to pass along some info that is interrupting the authentication of the agent?

Thank you for your help

Please sign in to leave a comment.