在IIS上远程发布构件到TeamCity服务器的问题

12

我在使用TeamCity时遇到了一个相当奇怪的问题。我有一个安装了TeamCity的服务器,以及本地和远程的构建代理。为了启用SSL等功能,TeamCity服务器隐藏在应用程序请求路由(ARR)后面的IIS中。我觉得这可能是问题的一部分,但我不确定。怀疑IIS是问题一部分的另一个原因是,我尝试在Azure Web应用上托管TeamCity,并且得到了完全相同的行为。

问题在于,在构建后,当构建代理试图将构件发布到服务器时,我从TeamCity服务器收到404响应。TeamCity认为这是可以恢复的错误(请参见日志),并尝试重新尝试几次。最终,发布失败了。

如果我将本地代理配置为通过http://localhost访问TeamCity,则一切正常运行。但是,当通过公共地址(通过IIS提供)访问时,我会收到404响应。 404内容看起来像标准的IIS 404页面。

我已经尝试将代理日志详细程度设置为DEBUG,但仍然无法输出它正在尝试调用的实际URL。

有人有任何提示可以解决这个问题吗?让TeamCity代理输出它收到404的URL将是一个好的开始。

[Publishing artifacts] Publishing 1 file [F:/tc/ba3/temp/buildTmp/out/_PublishedWebSites/**/* => dist.zip] using [WebPublisher]
[15:34:15][Publishing artifacts] Publishing 1 file [F:/tc/ba3/temp/buildTmp/out/_PublishedWebSites/**/* => dist.zip] using [ArtifactsCachePublisher]
[15:35:10]
[Publishing artifacts] Recoverable problem publishing artifacts (will retry): <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">;
<html xmlns="http://www.w3.org/1999/xhtml">;
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
<title>404 - File or directory not found.</title>
<style type="text/css">
<!--
body{margin:0;font-size:.7em;font-family:Verdana, Arial, Helvetica, sans-serif;background:#EEEEEE;}
fieldset{padding:0 15px 10px 15px;} 
h1{font-size:2.4em;margin:0;color:#FFF;}
h2{font-size:1.7em;margin:0;color:#CC0000;} 
h3{font-size:1.2em;margin:10px 0 0 0;color:#000000;} 
#header{width:96%;margin:0 0 0 0;padding:6px 2% 6px 2%;font-family:"trebuchet MS", Verdana, sans-serif;color:#FFF;
background-color:#555555;}
#content{margin:0 0 0 2%;position:relative;}
.content-container{background:#FFF;width:96%;margin-top:8px;padding:10px;position:relative;}
-->
</style>
</head>
<body>
<div id="header"><h1>Server Error</h1></div>
<div id="content">
 <div class="content-container"><fieldset>
  <h2>404 - File or directory not found.</h2>
  <h3>The resource you are looking for might have been removed, had its name changed, or is temporarily unavailable.</h3>
 </fieldset></div>
</div>
</body>
</html>
2个回答

19

编辑:在TeamCity页面上也有文档记录:

https://confluence.jetbrains.com/display/TCD9/Known+Issues#KnownIssues-FailuretopublishartifactstoserverbehindIISreverseproxy

像Terri Rougeou Donahue提到的那样,失败请求跟踪是帮助我的工具。我遇到了两个错误。

  1. 首先,StaticFileHandler没有关闭。因此,在尝试将POST发送到/httpAuth/artefactUpload.html URL时,StaticFileHandler试图在ARR处理请求之前处理它。
  2. 当我关闭StaticFileHandler时,RequestFiltering模块会启动,并返回404.13错误代码,表示“内容长度太大”。经过一些搜索,我找到了这个描述参数maxAllowedContentLength的网页http://www.iis.net/configreference/system.webserver/security/requestfiltering/requestlimits,并且说“默认值为30000000,约为28.6MB。”

解决方法如下:

  1. 对于该网站,关闭StaticFileHandler(处理程序映射)
  2. 编辑Web站点上的“请求筛选”设置属性,将“最大允许内容长度”设置为合理的值。我添加了一个0(使其约为286MB,因为工件可能很大)。

maxContentLength IIS settings window


3
昨天我们刚刚将服务器移至代理后面,我一直在苦苦思考如何解决问题。感谢您的帮助! - MattGWagner
2
相信我,在最终找到解决方案之前,我也曾经历了很多头痛(不是好的那种)。非常感谢 Stack Overflow 的帮助。 - Erik A. Brandstadmoen
1
当然,在提交了一张JetBrains的支持票据后,大约5分钟后我就找到了这个答案...无论如何,问题现在已经解决了。 - David Keaveny

3
您可以在TeamCity部署的IIS服务器上启用“故障请求跟踪”。这将提供404错误发生位置。请查看故障请求跟踪以获取更多信息。

谢谢您的提示。但是,我在IIS的“配置”下没有看到文章中提到的“失败请求跟踪”。 - Erik A. Brandstadmoen
"Tracing" Web 服务器功能也必须安装:http://www.iis.net/configreference/system.webserver/tracing/tracefailedrequests - Erik A. Brandstadmoen
Failed Request Tracing 是一个很好用的工具。出现了两个错误,我会创建自己的答案来进行详细阐述。 - Erik A. Brandstadmoen

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接